﻿#include "stdafx.h"
#include "HZData.h"
#include "JsonAnalysis.h"
#include <locale.h>
#include "iostream"
#include "fstream"
#include "UI/MsgBoxDlg.h"
#include "FileDlg.h"
#include "math.h"
CHZData::CHZData()
{
}


CHZData::~CHZData()
{

}

BOOL CHZData::IsData1_1Type(int nGuifanType, int nGuifan)
{
	return m_standard.IsData1_1Type(nGuifanType, nGuifan);
}

//随机数  范围：(nMin - nMax)/2 — (nMIn + nMax) / 2
int CHZData::GetRandVal(int nMin, int nMax)
{
	int nRes = rand() % (nMax - nMin + 1) + nMin;
	return nRes - (nMin + nMax) / 2;
}

//创造数据
void CHZData::CreateNewData(NEW_DATA New_Data)
{
	srand(time(0));

	DATA_TYPE DataType = GetDataType(New_Data.nGuiFanType, New_Data.nGuiFan);
	HZ_PROJECT_INFO Pro_Info;
	ZeroMemory(&Pro_Info, sizeof(Pro_Info));
	//规范
	Pro_Info.chStandardType = New_Data.nGuiFanType;
	Pro_Info.chStandard = New_Data.nGuiFan;
	Pro_Info.chMaxLoadType = New_Data.nMaxLoadType;
	Pro_Info.fChangePointAngle = 30;
	if (Pro_Info.chMaxLoadType == 1)
	{
		Pro_Info.chUnit = 1;
	}
	else
	{
		Pro_Info.chUnit = 0;
	}

	USES_CONVERSION;
	CString strVal(L"");
// 	CTime ct;
// 	ct = CTime::GetCurrentTime();
// 	strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");

	strVal = New_Data.chBeginTime;
	strcpy_s(Pro_Info.chTestDate, sizeof(Pro_Info.chTestDate), W2A(strVal));
	strcpy_s(Pro_Info.chUploadDate, sizeof(Pro_Info.chUploadDate), W2A(strVal));

	COleDateTime dtTest; //测试时间
	dtTest.ParseDateTime(strVal);
	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	//减10天
	ct -= 60 * 60 * 24 * 10;
	strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
	strcpy_s(Pro_Info.chWeiTuoDate, sizeof(Pro_Info.chWeiTuoDate), W2A(strVal));
	strcpy_s(Pro_Info.chShiGongDate, sizeof(Pro_Info.chShiGongDate), W2A(strVal));


	//抗拔实验
	if ((Pro_Info.chStandardType == 1 && Pro_Info.chStandard == 2)
		|| (Pro_Info.chStandardType == 1 && Pro_Info.chStandard == 16)
		|| (Pro_Info.chStandardType == 1 && Pro_Info.chStandard == 23)
		|| (Pro_Info.chStandardType == 1 && Pro_Info.chStandard == 24)
		|| (Pro_Info.chStandardType == 2 && Pro_Info.chStandard == 0)
		|| (Pro_Info.chStandardType == 2 && Pro_Info.chStandard == 2)
		|| (Pro_Info.chStandardType == 5 && Pro_Info.chStandard == 6)
		|| (Pro_Info.chStandardType == 5 && Pro_Info.chStandard == 14)
		)
	{
		CreateNewData3(New_Data, Pro_Info);
	}
	else if (Pro_Info.chStandardType == 5 && Pro_Info.chStandard == 8)//快速试验(DB32/T 3916-2020)
	{
		CreateNewData58(New_Data, Pro_Info);
	}
	else if (Pro_Info.chStandardType == 1 && Pro_Info.chStandard == 29)//蠕变试验(JGJ 120-2012)
	{
		CreateNewData1_29(New_Data, Pro_Info);
	}
	else if (DataType == DATA_1)
	{
		if (IsData1_1Type(Pro_Info.chStandardType, Pro_Info.chStandard))
		{
			CreateNewData1_1(New_Data, Pro_Info);
		}
		else if (Pro_Info.chStandardType == 4 && Pro_Info.chStandard == 3
			|| Pro_Info.chStandardType == 4 && Pro_Info.chStandard == 4)
		{
			CreateNewData4_3(New_Data, Pro_Info);
		}
		else
		{
			CreateNewData1(New_Data, Pro_Info);
		}
	}
	else if (DataType == DATA_2)
	{
		CreateNewData2(New_Data, Pro_Info);
	}
	else if (DataType == DATA_3)
	{
		CreateNewData3(New_Data, Pro_Info);
	}
	else
	{
		CreateNewData0(New_Data, Pro_Info);
	}
}

void CHZData::CreateNewData1_29(NEW_DATA New_Data, HZ_PROJECT_INFO Pro_Info)
{
	m_vLvDingInfo.clear();
	m_vDataInfo.clear();

	DATA_INFO Dt_Info;
	USES_CONVERSION;
	CString strVal(L"");
	float fVal = 0;
	float fLastVal = 0; //上一级位移
	strVal = L"虚拟工程";
	strcpy_s(Pro_Info.chProjectName, sizeof(Pro_Info.chProjectName), W2A(strVal));
	COleDateTime dtTest; //测试时间
	CString strText(L"");
	strText = Pro_Info.chTestDate;
	dtTest.ParseDateTime(strText);

	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

	memcpy(Pro_Info.chPileNum, "0001", sizeof(Pro_Info.chPileNum));
	Pro_Info.nMaxLoad = (float)New_Data.nMaxLoad;
	Pro_Info.nFirstLoad = New_Data.nFirstLoadGrade;


	Pro_Info.chXunHuanCnt = New_Data.nXunHuan;
	Pro_Info.nLoadTime = New_Data.nLoadTime;
	Pro_Info.nLoadoffTime = New_Data.nLoadoffTime;
	Pro_Info.nTableGap = New_Data.nTableGap;

	Pro_Info.nYuLoadGrade = New_Data.nLoadGrades;
	if (Pro_Info.nYuLoadGrade < 1)
	{
		Pro_Info.nYuLoadGrade = 1;
	}
	Pro_Info.nLoadGrade = New_Data.nLoadGrades + 1 - (Pro_Info.nFirstLoad - 1);
	fVal = (float)(Pro_Info.nMaxLoad / (10 * 1.0));
	Pro_Info.fLoadList[0] = 0;
// 	for (int i = 1; i < Pro_Info.nLoadGrade; ++i)
// 	{
// 		Pro_Info.fLoadList[i] = (float)fVal * (i - 1 + Pro_Info.nFirstLoad);
// 	}
	Pro_Info.fLoadList[0] = 0;
	Pro_Info.fLoadList[1] = fVal * 5;
	Pro_Info.fLoadList[2] = fVal * 7.5;
	Pro_Info.fLoadList[3] = fVal * 10;
	Pro_Info.fLoadList[4] = fVal * 12;
	Pro_Info.fLoadList[5] = fVal * 15;
	for (int i = 6; i < Pro_Info.nLoadGrade; ++i)
	{
		Pro_Info.fLoadList[i] = fVal * (i+1) * 2.5;
	}

	//Pro_Info.fLoadList[Pro_Info.nLoadGrade - 1] = (float)Pro_Info.nMaxLoad;
	//卸载分级
	Pro_Info.nLoadoffGrade = New_Data.nLoadoffGrades;
	if (Pro_Info.nLoadoffGrade < 1)
	{
		Pro_Info.nLoadoffGrade = 1;
	}
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nLoadoffGrade * 1.0));
	for (int i = 0; i < Pro_Info.nLoadoffGrade; ++i)
	{
		Pro_Info.fLoadoffList[i] = (float)(Pro_Info.nLoadoffGrade - i - 1) * fVal;
	}

	Pro_Info.fW = 0;
	Pro_Info.fr1 = 1;
	Pro_Info.fLu = 1;
	Pro_Info.fEp = 1000;
	Pro_Info.fAp = 1;

	Pro_Info.nPileDiam = 100;
	Pro_Info.nPileDiamW = 100;
	Pro_Info.fPilelength = 10.00;
	memcpy(Pro_Info.chTestNo, "T0001", sizeof(Pro_Info.chTestNo));
	Pro_Info.chTestType = 0;
	//	Pro_Info.chUnit = 0;
	Pro_Info.chShape = 0;
	Pro_Info.chPileUsed = 0;
	Pro_Info.chRes1[7];
	memcpy(Pro_Info.chJackNum, "0000", sizeof(Pro_Info.chJackNum));
	Pro_Info.nJackCnts = 1;
	Pro_Info.nJackDiam = 10;
	Pro_Info.chJackType = 0;
	Pro_Info.chWeiYiSensorType = 0;
	Pro_Info.chYaLiSensorType = 0;
	Pro_Info.chPlateType = 0;
	memcpy(Pro_Info.chWeiYiSensorNum, "", sizeof(Pro_Info.chWeiYiSensorNum));
	memcpy(Pro_Info.chYaLiSensorNum, "Y0001", sizeof(Pro_Info.chYaLiSensorNum));
	Pro_Info.fPlateArea = 1;
	for (int i = 0; i < 8; i++)
	{
		if (New_Data.bChannelSel[i])
		{
			Pro_Info.chChanelUsed[i] = 1;
			Pro_Info.chChannelSel[i] = 1;
		}
		else
		{
			Pro_Info.chChanelUsed[i] = 0;
			Pro_Info.chChannelSel[i] = 0;
		}

	}

	for (int i = 0; i < 12; ++i)
	{
		Pro_Info.nLoadTimeList[i] = New_Data.nLoadTimeGap[i];
		Pro_Info.nLoadOffTimeList[i] = New_Data.nLoadoffTimeGap[i];
	}
	Pro_Info.nSignCnts = 0;
	int nTimeGap = 5;
	Pro_Info.nDataCnt = nTimeGap * (Pro_Info.nLoadGrade + Pro_Info.nLoadoffGrade);
	//0时就一个值
	Pro_Info.nDataCnt = Pro_Info.nDataCnt - nTimeGap + 1;
	int nCnt = 0;
	int nBenjiId = 0;
	BOOL bBenjiChange = FALSE;
	float fYouya = 0;
	float fWeiyi = 0;
	float fAddVal = 0.05;		//每级增加位移
	float fMinusVal = 0.02;		//每级减少位移
	if (New_Data.bMaxWeiyi)
	{
		fAddVal = New_Data.fMaxWeiyi / Pro_Info.nLoadGrade;
		fMinusVal = fAddVal / 3;
		fAddVal = Carry(fAddVal, 2);
		fMinusVal = Carry(fMinusVal, 2);
	}
	float fWeiYiDest = 0;
	for (int i = 0; i < Pro_Info.nDataCnt; ++i)
	{
		if (nCnt == nTimeGap)
		{
			nCnt = 0;
			nBenjiId++;
			if (!bBenjiChange && nBenjiId >= Pro_Info.nLoadGrade)
			{
				nBenjiId = 0;
				bBenjiChange = TRUE;
			}
			if (bBenjiChange)
			{
				fYouya -= (float)0.1;
				if (fYouya < 0)
				{
					fYouya = 0;
				}

				fWeiyi -= fMinusVal + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				if (fWeiyi < 0)
				{
					fWeiyi = 0;
				}
			}
			else
			{
				fYouya += (float)0.1;
				fWeiyi += fAddVal + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
			}
			fWeiYiDest = fWeiyi;
		}
		if (nCnt == 0)
		{
			fWeiyi = fLastVal;
		}
		else
		{
			fLastVal = fWeiYiDest;
			fWeiyi = fWeiYiDest;
		}


		ZeroMemory(&Dt_Info, sizeof(DATA_INFO));
		Dt_Info.chBeiZhu[0] = '\0';
		ct += 60;
		strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
		strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		Dt_Info.nRecordId = nCnt;
		Dt_Info.nIdx = nBenjiId;
		if (bBenjiChange)
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;
			Dt_Info.nTimeGap = /*Pro_Info.nLoadOffTimeList[nCnt]*/1;
			if (nCnt < 12)
			{
				Dt_Info.nTimeGap = Pro_Info.nLoadOffTimeList[nCnt];
			}
			else{
				Dt_Info.nTimeGap = Pro_Info.nLoadOffTimeList[11];
			}
		}
		else
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			if (i == 0)
			{
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[nCnt]*/ 0;
				Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[0];
			}
			else
			{
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[nCnt]*/ 1;
				if (nCnt < 12)
				{
					Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[nCnt];
				}
				else{
					Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[11];
				}
			}

		}
		Dt_Info.fCurYouya = fYouya;

		Dt_Info.fWeiyiAvg = fWeiyi;
		Dt_Info.fShangZhuangShangBa = fWeiyi;
		for (int m = 0; m < 8; ++m)
		{
			Dt_Info.fWeiyi[m] = fWeiyi;
		}
		nCnt++;
		if (0 == i)
		{
			nCnt = nTimeGap;
			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		}
		m_vDataInfo.push_back(Dt_Info);
	}

	m_HZProInfo = Pro_Info;
	m_HZProInfo_Old = Pro_Info;
	m_vDataInfo_Old = m_vDataInfo;

	SetCurveUnit(m_HZProInfo);
	InitCalcData();
}

void CHZData::CreateNewData58(NEW_DATA New_Data, HZ_PROJECT_INFO Pro_Info)
{
	m_vLvDingInfo.clear();
	m_vDataInfo.clear();

	DATA_INFO Dt_Info;
	USES_CONVERSION;
	CString strVal(L"");
	float fVal = 0;
	float fLastVal = 0; //上一级位移
	strVal = L"虚拟工程";
	strcpy_s(Pro_Info.chProjectName, sizeof(Pro_Info.chProjectName), W2A(strVal));


	COleDateTime dtTest; //测试时间
	CString strText(L"");
	strText = Pro_Info.chTestDate;
	dtTest.ParseDateTime(strText);

	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

	memcpy(Pro_Info.chPileNum, "0001", sizeof(Pro_Info.chPileNum));
	Pro_Info.nMaxLoad = (float)New_Data.nMaxLoad;
	Pro_Info.nFirstLoad = New_Data.nFirstLoadGrade;


	Pro_Info.chXunHuanCnt = New_Data.nXunHuan;
	Pro_Info.nLoadTime = New_Data.nLoadTime;
	Pro_Info.nLoadoffTime = New_Data.nLoadoffTime;
	Pro_Info.nTableGap = New_Data.nTableGap;

	Pro_Info.nYuLoadGrade = New_Data.nLoadGrades;
	if (Pro_Info.nYuLoadGrade < 1)
	{
		Pro_Info.nYuLoadGrade = 1;
	}
	Pro_Info.nLoadGrade = New_Data.nLoadGrades + 1 - (Pro_Info.nFirstLoad - 1);
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nYuLoadGrade * 1.0));
	Pro_Info.fLoadList[0] = 0;
	Pro_Info.fLoadList[1] = fVal * 2;
	Pro_Info.fLoadList[2] = fVal * 5;
	Pro_Info.fLoadList[3] = fVal * 7;
	Pro_Info.fLoadList[4] = fVal * 9;
	Pro_Info.fLoadList[5] = fVal * 10;
	Pro_Info.nLoadGrade = 6;
	//卸载分级
	Pro_Info.nLoadoffGrade = New_Data.nLoadoffGrades;
	if (Pro_Info.nLoadoffGrade < 1)
	{
		Pro_Info.nLoadoffGrade = 1;
	}
 	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nLoadoffGrade * 1.0));
	Pro_Info.fLoadoffList[0] = fVal * 5;
	Pro_Info.fLoadoffList[1] = fVal * 2;
	Pro_Info.fLoadoffList[2] = fVal * 0;
	Pro_Info.nLoadoffGrade = 3;

	Pro_Info.fW = 0;
	Pro_Info.fr1 = 1;
	Pro_Info.fLu = 1;
	Pro_Info.fEp = 1000;
	Pro_Info.fAp = 1;

	Pro_Info.nPileDiam = 100;
	Pro_Info.nPileDiamW = 100;
	Pro_Info.fPilelength = 10.00;
	memcpy(Pro_Info.chTestNo, "T0001", sizeof(Pro_Info.chTestNo));
	Pro_Info.chTestType = 0;
	//	Pro_Info.chUnit = 0;
	Pro_Info.chShape = 0;
	Pro_Info.chPileUsed = 0;
	Pro_Info.chRes1[7];
	memcpy(Pro_Info.chJackNum, "0000", sizeof(Pro_Info.chJackNum));
	Pro_Info.nJackCnts = 1;
	Pro_Info.nJackDiam = 10;
	Pro_Info.chJackType = 0;
	Pro_Info.chWeiYiSensorType = 0;
	Pro_Info.chYaLiSensorType = 0;
	Pro_Info.chPlateType = 0;
	memcpy(Pro_Info.chWeiYiSensorNum, "", sizeof(Pro_Info.chWeiYiSensorNum));
	memcpy(Pro_Info.chYaLiSensorNum, "Y0001", sizeof(Pro_Info.chYaLiSensorNum));
	Pro_Info.fPlateArea = 1;
	for (int i = 0; i < 8; i++)
	{
		if (New_Data.bChannelSel[i])
		{
			Pro_Info.chChanelUsed[i] = 1;
			Pro_Info.chChannelSel[i] = 1;
		}
		else
		{
			Pro_Info.chChanelUsed[i] = 0;
			Pro_Info.chChannelSel[i] = 0;
		}

	}

	for (int i = 0; i < 12; ++i)
	{
		Pro_Info.nLoadTimeList[i] = New_Data.nLoadTimeGap[i];
		Pro_Info.nLoadOffTimeList[i] = New_Data.nLoadoffTimeGap[i];
	}
	Pro_Info.nSignCnts = 0;
	int nTimeGap = 5;
	Pro_Info.nDataCnt = nTimeGap * (Pro_Info.nLoadGrade + Pro_Info.nLoadoffGrade);
	//0时就一个值
	Pro_Info.nDataCnt = Pro_Info.nDataCnt - nTimeGap + 1;
	int nCnt = 0;
	int nBenjiId = 0;
	BOOL bBenjiChange = FALSE;
	float fYouya = 0;
	float fWeiyi = 0;
	float fAddVal = 1;		//每级增加位移
	float fMinusVal = 0.5;		//每级减少位移
	if (New_Data.bMaxWeiyi)
	{
		fAddVal = New_Data.fMaxWeiyi / Pro_Info.nLoadGrade;
		fMinusVal = fAddVal / 2;
		fAddVal = Carry(fAddVal, 2);
		fMinusVal = Carry(fMinusVal, 2);
	}
	float fWeiYiDest = 0;
	for (int i = 0; i < Pro_Info.nDataCnt; ++i)
	{
		if (nCnt == nTimeGap)
		{
			nCnt = 0;
			nBenjiId++;
			if (!bBenjiChange && nBenjiId >= Pro_Info.nLoadGrade)
			{
				nBenjiId = 0;
				bBenjiChange = TRUE;
			}
			if (bBenjiChange)
			{
				fYouya -= (float)0.1;
				if (fYouya < 0)
				{
					fYouya = 0;
				}

				fWeiyi -= fMinusVal + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				if (fWeiyi < 0)
				{
					fWeiyi = 0;
				}
			}
			else
			{
				fYouya += (float)0.1;
				fWeiyi += fAddVal + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
			}
			fWeiYiDest = fWeiyi ;
		}
		if (nCnt == 0)
		{
			fWeiyi = fLastVal;
		}
		else
		{
			fLastVal = fWeiYiDest;
			fWeiyi = fWeiYiDest;
		}


		ZeroMemory(&Dt_Info, sizeof(DATA_INFO));
		Dt_Info.chBeiZhu[0] = '\0';
		ct += 60;
		strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
		strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		Dt_Info.nRecordId = nCnt;
		Dt_Info.nIdx = nBenjiId;
		if (bBenjiChange)
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;
			Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[nCnt];
		}
		else
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[nCnt];
		}
		Dt_Info.fCurYouya = fYouya;

		Dt_Info.fWeiyiAvg = fWeiyi;
		Dt_Info.fShangZhuangShangBa = fWeiyi;
		for (int m = 0; m < 8; ++m)
		{
			Dt_Info.fWeiyi[m] = fWeiyi;
		}
		nCnt++;
		if (0 == i)
		{
			nCnt = nTimeGap;
			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		}
		m_vDataInfo.push_back(Dt_Info);
	}

	m_HZProInfo = Pro_Info;
	m_HZProInfo_Old = Pro_Info;
	m_vDataInfo_Old = m_vDataInfo;

	SetCurveUnit(m_HZProInfo);
	InitCalcData();
}

//自平衡
void CHZData::CreateNewData3(NEW_DATA New_Data, HZ_PROJECT_INFO Pro_Info)
{
	m_vLvDingInfo.clear();
	m_vDataInfo.clear();

	DATA_INFO Dt_Info;
	USES_CONVERSION;
	CString strVal(L"");
	float fVal = 0;
	float fLastVal = 0; //上一级位移
	strVal = L"虚拟工程";
	strcpy_s(Pro_Info.chProjectName, sizeof(Pro_Info.chProjectName), W2A(strVal));
// 	CTime ct;
// 	ct = CTime::GetCurrentTime();
// 	strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
// 	strcpy_s(Pro_Info.chTestDate, sizeof(Pro_Info.chTestDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chWeiTuoDate, sizeof(Pro_Info.chWeiTuoDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chShiGongDate, sizeof(Pro_Info.chShiGongDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chUploadDate, sizeof(Pro_Info.chUploadDate), W2A(strVal));

	COleDateTime dtTest; //测试时间
	CString strText(L"");
	strText = Pro_Info.chTestDate;
	dtTest.ParseDateTime(strText);

	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));


	memcpy(Pro_Info.chPileNum, "0001", sizeof(Pro_Info.chPileNum));
	Pro_Info.nMaxLoad = (float)New_Data.nMaxLoad;
	Pro_Info.nFirstLoad = New_Data.nFirstLoadGrade;


	Pro_Info.chXunHuanCnt = New_Data.nXunHuan;
	Pro_Info.nLoadTime = New_Data.nLoadTime;
	Pro_Info.nLoadoffTime = New_Data.nLoadoffTime;
	Pro_Info.nTableGap = New_Data.nTableGap;

	Pro_Info.nYuLoadGrade = New_Data.nLoadGrades;
	if (Pro_Info.nYuLoadGrade < 1)
	{
		Pro_Info.nYuLoadGrade = 1;
	}
	Pro_Info.nLoadGrade = New_Data.nLoadGrades + 1 - (Pro_Info.nFirstLoad - 1);
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nYuLoadGrade * 1.0));
	Pro_Info.fLoadList[0] = 0;
	for (int i = 1; i < Pro_Info.nLoadGrade; ++i)
	{
		Pro_Info.fLoadList[i] = (float)fVal * (i - 1 + Pro_Info.nFirstLoad);
	}
	Pro_Info.fLoadList[Pro_Info.nLoadGrade - 1] = (float)Pro_Info.nMaxLoad;
	//卸载分级
	Pro_Info.nLoadoffGrade = New_Data.nLoadoffGrades;
	if (Pro_Info.nLoadoffGrade < 1)
	{
		Pro_Info.nLoadoffGrade = 1;
	}
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nLoadoffGrade * 1.0));
	for (int i = 0; i < Pro_Info.nLoadoffGrade; ++i)
	{
		Pro_Info.fLoadoffList[i] = (float)(Pro_Info.nLoadoffGrade - i - 1) * fVal;
	}

	Pro_Info.fW = 0;
	Pro_Info.fr1 = 1;
	Pro_Info.fLu = 1;
	Pro_Info.fEp = 1000;
	Pro_Info.fAp = 1;

	Pro_Info.nPileDiam = 100;
	Pro_Info.nPileDiamW = 100;
	Pro_Info.fPilelength = 10.00;
	memcpy(Pro_Info.chTestNo, "T0001", sizeof(Pro_Info.chTestNo));
	Pro_Info.chTestType = 0;
	//	Pro_Info.chUnit = 0;
	Pro_Info.chShape = 0;
	Pro_Info.chPileUsed = 0;
	Pro_Info.chRes1[7];
	memcpy(Pro_Info.chJackNum, "0000", sizeof(Pro_Info.chJackNum));
	Pro_Info.nJackCnts = 1;
	Pro_Info.nJackDiam = 10;
	Pro_Info.chJackType = 0;
	Pro_Info.chWeiYiSensorType = 0;
	Pro_Info.chYaLiSensorType = 0;
	Pro_Info.chPlateType = 0;
	memcpy(Pro_Info.chWeiYiSensorNum, "", sizeof(Pro_Info.chWeiYiSensorNum));
	memcpy(Pro_Info.chYaLiSensorNum, "Y0001", sizeof(Pro_Info.chYaLiSensorNum));
	Pro_Info.fPlateArea = 1;
	for (int i = 0; i < 8; i++)
	{
		if (New_Data.bChannelSel[i])
		{
			Pro_Info.chChanelUsed[i] = 1;
			Pro_Info.chChannelSel[i] = 1;
		}
		else
		{
			Pro_Info.chChanelUsed[i] = 0;
			Pro_Info.chChannelSel[i] = 0;
		}

	}

	for (int i = 0; i < 12; ++i)
	{
		Pro_Info.nLoadTimeList[i] = New_Data.nLoadTimeGap[i];
		Pro_Info.nLoadOffTimeList[i] = New_Data.nLoadoffTimeGap[i];
	}
	Pro_Info.nSignCnts = 0;
	int nTimeGap = 5;
	Pro_Info.nDataCnt = nTimeGap * (Pro_Info.nLoadGrade + Pro_Info.nLoadoffGrade);
	//0时就一个值
	Pro_Info.nDataCnt = Pro_Info.nDataCnt - nTimeGap + 1;
	int nCnt = 0;
	int nBenjiId = 0;
	BOOL bBenjiChange = FALSE;
	float fYouya = 0;
	float fWeiyi = 0;
	float fAddVal = 1;		//每级增加位移
	float fMinusVal = 0.5;		//每级减少位移
	if (New_Data.bMaxWeiyi)
	{
		fAddVal = New_Data.fMaxWeiyi / Pro_Info.nLoadGrade;
		fMinusVal = fAddVal / 2;
		fAddVal = Carry(fAddVal, 2);
		fMinusVal = Carry(fMinusVal, 2);
	}
	float fWeiYiDest = 0;
	for (int i = 0; i < Pro_Info.nDataCnt; ++i)
	{
		if (nCnt == nTimeGap)
		{
			nCnt = 0;
			nBenjiId++;
			if (!bBenjiChange && nBenjiId >= Pro_Info.nLoadGrade)
			{
				nBenjiId = 0;
				bBenjiChange = TRUE;
			}
			if (bBenjiChange)
			{
				fYouya -= (float)0.1;
				if (fYouya < 0)
				{
					fYouya = 0;
				}

				fWeiyi -= fMinusVal + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				if (fWeiyi < 0)
				{
					fWeiyi = 0;
				}
			}
			else
			{
				fYouya += (float)0.1;
				fWeiyi += fAddVal + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
			}
			fWeiYiDest = fWeiyi;
		}
		if (nCnt == 0)
		{
			fWeiyi = fLastVal;
		}
		else
		{
			fLastVal = fWeiYiDest;
			fWeiyi = fWeiYiDest;
		}


		ZeroMemory(&Dt_Info, sizeof(DATA_INFO));
		Dt_Info.chBeiZhu[0] = '\0';
		ct += 60;
		strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
		strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		Dt_Info.nRecordId = nCnt;
		Dt_Info.nIdx = nBenjiId;
		if (bBenjiChange)
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;
			Dt_Info.nTimeGap = /*Pro_Info.nLoadOffTimeList[nCnt]*/1;
		}
		else
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			if (i == 0)
			{
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[nCnt]*/ 0;
			}
			else
			{
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[nCnt]*/ 1;
			}

		}
		Dt_Info.fCurYouya = fYouya;

		Dt_Info.fWeiyiAvg = fWeiyi;
		Dt_Info.fShangZhuangShangBa = fWeiyi;
		for (int m = 0; m < 8; ++m)
		{
			Dt_Info.fWeiyi[m] = fWeiyi;
		}
		nCnt++;
		if (0 == i)
		{
			nCnt = nTimeGap;
			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		}
		m_vDataInfo.push_back(Dt_Info);
	}

	m_HZProInfo = Pro_Info;
	m_HZProInfo_Old = Pro_Info;
	m_vDataInfo_Old = m_vDataInfo;

	SetCurveUnit(m_HZProInfo);
	InitCalcData();
}

void CHZData::CreateNewData0(NEW_DATA New_Data, HZ_PROJECT_INFO Pro_Info)
{
	m_vLvDingInfo.clear();
	m_vDataInfo.clear();
	
	DATA_INFO Dt_Info;
	USES_CONVERSION;
	CString strVal(L"");
	float fVal = 0;
	float fLastVal = 0; //上一级位移
	strVal = L"虚拟工程";
	strcpy_s(Pro_Info.chProjectName, sizeof(Pro_Info.chProjectName), W2A(strVal));
	COleDateTime dtTest; //测试时间
	CString strText(L"");
	strText = Pro_Info.chTestDate;
	dtTest.ParseDateTime(strText);

	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

	memcpy(Pro_Info.chPileNum, "0001", sizeof(Pro_Info.chPileNum));
	Pro_Info.nMaxLoad = (float)New_Data.nMaxLoad;
	Pro_Info.nFirstLoad = New_Data.nFirstLoadGrade;


	Pro_Info.chXunHuanCnt = New_Data.nXunHuan;
	Pro_Info.nLoadTime = New_Data.nLoadTime;
	Pro_Info.nLoadoffTime = New_Data.nLoadoffTime;
	Pro_Info.nTableGap = New_Data.nTableGap;

	Pro_Info.nYuLoadGrade = New_Data.nLoadGrades;
	if (Pro_Info.nYuLoadGrade < 1)
	{
		Pro_Info.nYuLoadGrade = 1;
	}
	Pro_Info.nLoadGrade = New_Data.nLoadGrades + 1 - (Pro_Info.nFirstLoad - 1);
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nYuLoadGrade * 1.0));
	Pro_Info.fLoadList[0] = 0;
	for (int i = 1; i < Pro_Info.nLoadGrade; ++i)
	{
		Pro_Info.fLoadList[i] = (float)fVal * (i - 1 + Pro_Info.nFirstLoad);
	}
	Pro_Info.fLoadList[Pro_Info.nLoadGrade - 1] = (float)Pro_Info.nMaxLoad;
	//卸载分级
	Pro_Info.nLoadoffGrade = New_Data.nLoadoffGrades;
	if (Pro_Info.nLoadoffGrade < 1)
	{
		Pro_Info.nLoadoffGrade = 1;
	}
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nLoadoffGrade * 1.0));
	for (int i = 0; i < Pro_Info.nLoadoffGrade; ++i)
	{
		Pro_Info.fLoadoffList[i] = (float)(Pro_Info.nLoadoffGrade - i - 1) * fVal;
	}

	Pro_Info.fW = 0;
	Pro_Info.fr1 = 1;
	Pro_Info.fLu = 1;
	Pro_Info.fEp = 1000;
	Pro_Info.fAp = 1;

	Pro_Info.nPileDiam = 100;
	Pro_Info.nPileDiamW = 100;
	Pro_Info.fPilelength = 10.00;
	memcpy(Pro_Info.chTestNo, "T0001", sizeof(Pro_Info.chTestNo));
	Pro_Info.chTestType = 0;
//	Pro_Info.chUnit = 0;
	Pro_Info.chShape = 0;
	Pro_Info.chPileUsed = 0;
	Pro_Info.chRes1[7];
	memcpy(Pro_Info.chJackNum, "0000", sizeof(Pro_Info.chJackNum));
	Pro_Info.nJackCnts = 1;
	Pro_Info.nJackDiam = 10;
	Pro_Info.chJackType = 0;
	Pro_Info.chWeiYiSensorType = 0;
	Pro_Info.chYaLiSensorType = 0;
	Pro_Info.chPlateType = 0;
	memcpy(Pro_Info.chWeiYiSensorNum, "", sizeof(Pro_Info.chWeiYiSensorNum));
	memcpy(Pro_Info.chYaLiSensorNum, "Y0001", sizeof(Pro_Info.chYaLiSensorNum));
	Pro_Info.fPlateArea = 1;
	for (int i = 0; i < 8; i++)
	{
		if (New_Data.bChannelSel[i])
		{
			Pro_Info.chChanelUsed[i] = 1;
			Pro_Info.chChannelSel[i] = 1;
		}
		else
		{
			Pro_Info.chChanelUsed[i] = 0;
			Pro_Info.chChannelSel[i] = 0;
		}

	}

	for (int i = 0; i < 12; ++i)
	{
		Pro_Info.nLoadTimeList[i] = New_Data.nLoadTimeGap[i];
		Pro_Info.nLoadOffTimeList[i] = New_Data.nLoadoffTimeGap[i];
	}
	Pro_Info.nSignCnts = 0;
	int nTimeGap = 5;
	Pro_Info.nDataCnt = nTimeGap * (Pro_Info.nLoadGrade + Pro_Info.nLoadoffGrade);
	//0时就一个值
	Pro_Info.nDataCnt = Pro_Info.nDataCnt - nTimeGap + 1;
	int nCnt = 0;
	int nBenjiId = 0;
	BOOL bBenjiChange = FALSE;
	float fYouya = 0;
	float fWeiyi = 0;
	float fAddVal = 0.05;		//每级增加位移
	float fMinusVal = 0.02;		//每级减少位移
	if (New_Data.bMaxWeiyi)
	{
		fAddVal = New_Data.fMaxWeiyi / Pro_Info.nLoadGrade;
		fMinusVal = fAddVal / 3;
		fAddVal = Carry(fAddVal, 2);
		fMinusVal = Carry(fMinusVal, 2);
	}
	float fWeiYiDest = 0;
	for (int i = 0; i < Pro_Info.nDataCnt; ++i)
	{
		if (nCnt == nTimeGap)
		{
			nCnt = 0;
			nBenjiId++;
			if (!bBenjiChange && nBenjiId >= Pro_Info.nLoadGrade)
			{
				nBenjiId = 0;
				bBenjiChange = TRUE;
			}
			if (bBenjiChange)
			{
				fYouya -= (float)0.1;
				if (fYouya < 0)
				{
					fYouya = 0;
				}

				fWeiyi -= fMinusVal + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				if (fWeiyi < 0)
				{
					fWeiyi = 0;
				}
			}
			else
			{
				fYouya += (float)0.1;
				fWeiyi += fAddVal + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
			}
			fWeiYiDest = fWeiyi;
		}
		if (nCnt == 0)
		{
			fWeiyi = fLastVal;
		}
		else
		{
			fLastVal = fWeiYiDest;
			fWeiyi = fWeiYiDest;
		}


		ZeroMemory(&Dt_Info, sizeof(DATA_INFO));
		Dt_Info.chBeiZhu[0] = '\0';
		ct += 60;
		strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
		strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		Dt_Info.nRecordId = nCnt;
		Dt_Info.nIdx = nBenjiId;
		if (bBenjiChange)
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;
			Dt_Info.nTimeGap = /*Pro_Info.nLoadOffTimeList[nCnt]*/1;
		}
		else
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			if (i ==0)
			{
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[nCnt]*/ 0;
			}
			else
			{
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[nCnt]*/ 1;
			}
			
		}
		Dt_Info.fCurYouya = fYouya;

		Dt_Info.fWeiyiAvg = fWeiyi;
		Dt_Info.fShangZhuangShangBa = fWeiyi;
		for (int m = 0; m < 8; ++m)
		{
			Dt_Info.fWeiyi[m] = fWeiyi;
		}
		nCnt++;
		if (0 == i)
		{
			nCnt = nTimeGap;
			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		}
		m_vDataInfo.push_back(Dt_Info);
	}

	m_HZProInfo = Pro_Info;
	m_HZProInfo_Old = Pro_Info;
	m_vDataInfo_Old = m_vDataInfo;

	SetCurveUnit(m_HZProInfo);
	InitCalcData();
}

void CHZData::CreateNewData2(NEW_DATA New_Data, HZ_PROJECT_INFO Pro_Info)
{
	m_vLvDingInfo.clear();
	m_vDataInfo.clear();

	DATA_INFO Dt_Info;
	Dt_Info.chBeiZhu[0] = '\0';
	USES_CONVERSION;
	CString strVal(L"");
	float fVal = 0;
	float fLastVal = 0; //上一级位移
	strVal = L"虚拟工程";
	strcpy_s(Pro_Info.chProjectName, sizeof(Pro_Info.chProjectName), W2A(strVal));
// 	CTime ct;
// 	ct = CTime::GetCurrentTime();
// 	strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
// 	strcpy_s(Pro_Info.chTestDate, sizeof(Pro_Info.chTestDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chWeiTuoDate, sizeof(Pro_Info.chWeiTuoDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chShiGongDate, sizeof(Pro_Info.chShiGongDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chUploadDate, sizeof(Pro_Info.chUploadDate), W2A(strVal));
	COleDateTime dtTest; //测试时间
	CString strText(L"");
	strText = Pro_Info.chTestDate;
	dtTest.ParseDateTime(strText);

	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));


	memcpy(Pro_Info.chPileNum, "0001", sizeof(Pro_Info.chPileNum));
	Pro_Info.nMaxLoad = (float)New_Data.nMaxLoad;
	Pro_Info.nFirstLoad = New_Data.nFirstLoadGrade;

	Pro_Info.chXunHuanCnt = New_Data.nXunHuan;
	Pro_Info.nLoadTime = New_Data.nLoadTime;
	Pro_Info.nLoadoffTime = New_Data.nLoadoffTime;
	Pro_Info.nTableGap = New_Data.nTableGap;

	Pro_Info.nYuLoadGrade = New_Data.nLoadGrades;
	Pro_Info.nLoadGrade = New_Data.nLoadGrades + 1 - (Pro_Info.nFirstLoad - 1);
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nYuLoadGrade * 1.0));
	float fLoadValGap = fVal;

	Pro_Info.fLoadList[0] = 0;
	for (int i = 1; i < Pro_Info.nLoadGrade; ++i)
	{
		Pro_Info.fLoadList[i] = (float)fVal * (i - 1 + Pro_Info.nFirstLoad);
	}
	Pro_Info.fLoadList[Pro_Info.nLoadGrade - 1] = (float)Pro_Info.nMaxLoad;
	//卸载分级
	Pro_Info.nLoadoffGrade = New_Data.nLoadoffGrades;

	Pro_Info.fW = 0;
	Pro_Info.fr1 = 1;
	Pro_Info.fLu = 1;
	Pro_Info.fEp = 1000;
	Pro_Info.fAp = 1;

	Pro_Info.nPileDiam = 100;
	Pro_Info.nPileDiamW = 100;
	Pro_Info.fPilelength = 10.00;
	memcpy(Pro_Info.chTestNo, "T0001", sizeof(Pro_Info.chTestNo));
	Pro_Info.chTestType = 0;
	//Pro_Info.chUnit = 0;
	Pro_Info.chShape = 0;
	Pro_Info.chPileUsed = 0;
	Pro_Info.chRes1[7];
	memcpy(Pro_Info.chJackNum, "0000", sizeof(Pro_Info.chJackNum));
	Pro_Info.nJackCnts = 1;
	Pro_Info.nJackDiam = 10;
	Pro_Info.chJackType = 0;
	Pro_Info.chWeiYiSensorType = 0;
	Pro_Info.chYaLiSensorType = 0;
	Pro_Info.chPlateType = 0;
	memcpy(Pro_Info.chWeiYiSensorNum, "", sizeof(Pro_Info.chWeiYiSensorNum));
	memcpy(Pro_Info.chYaLiSensorNum, "Y0001", sizeof(Pro_Info.chYaLiSensorNum));
	Pro_Info.fPlateArea = 1;
	for (int i = 0; i < 8; i++)
	{
		if (New_Data.bChannelSel[i])
		{
			Pro_Info.chChanelUsed[i] = 1;
			Pro_Info.chChannelSel[i] = 1;
		}
		else
		{
			Pro_Info.chChanelUsed[i] = 0;
			Pro_Info.chChannelSel[i] = 0;
		}
	}

	for (int i = 0; i < 12; ++i)
	{
		Pro_Info.nLoadTimeList[i] = New_Data.nLoadTimeGap[i];
		Pro_Info.nLoadOffTimeList[i] = New_Data.nLoadoffTimeGap[i];
	}
	Pro_Info.nSignCnts = 0;
	int nTimeGap = 5;
	//0时就一个值
	float fWeiyi = 0.00f;
	for (int i = 0; i < Pro_Info.nYuLoadGrade/* - Pro_Info.nFirstLoad - 3*/; ++i)
	{
		if (0 == i)
		{
			Dt_Info.nRecordId = 0;
			Dt_Info.nIdx = 0;
			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
			Dt_Info.fCurLoad = 0;
			Dt_Info.fLoadValue = 0;
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			Dt_Info.nTimeGap = 0;
			Dt_Info.fCurYouya = 0;
			Dt_Info.fWeiyiAvg = 0;
			for (int m = 0; m < 8; ++m)
			{
				Dt_Info.fWeiyi[m] = 0;
			}
			Dt_Info.fShangZhuangShangBa = 0;
			m_vDataInfo.push_back(Dt_Info);		
			continue;
		}
		for (int j = 0; j < Pro_Info.chXunHuanCnt; ++j)
		{
			if (j == 0)
			{
				Dt_Info.nRecordId = j;
				Dt_Info.nIdx = i;
				ct += 60;
				strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
				strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

				Dt_Info.fCurLoad = Pro_Info.fLoadList[i];
				Dt_Info.fLoadValue = Dt_Info.fCurLoad;
				Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
				Dt_Info.nTimeGap = 1;
				Dt_Info.fCurYouya = Dt_Info.fCurLoad / 10;
				fWeiyi += 1;
				Dt_Info.fWeiyiAvg = fWeiyi;
				for (int m = 0; m < 8; ++m)
				{
					Dt_Info.fWeiyi[m] = Dt_Info.fWeiyiAvg;
				}
				Dt_Info.fShangZhuangShangBa += 4;
				m_vDataInfo.push_back(Dt_Info);
			}
			
			Dt_Info.nRecordId++;
			Dt_Info.nIdx = i;
			ct += 30;
			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

			Dt_Info.fCurLoad = Pro_Info.fLoadList[i];
			Dt_Info.fLoadValue = Dt_Info.fCurLoad;
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			Dt_Info.nTimeGap = 1;
			Dt_Info.fCurYouya = Dt_Info.fCurLoad / 10;
			fWeiyi += 0.4;
			Dt_Info.fWeiyiAvg = fWeiyi;
			for (int m = 0; m < 8; ++m)
			{
				Dt_Info.fWeiyi[m] = Dt_Info.fWeiyiAvg;
			}
			Dt_Info.fShangZhuangShangBa += 4;
			m_vDataInfo.push_back(Dt_Info);


			Dt_Info.nRecordId++;
			Dt_Info.nIdx = i;
			ct += 60;
			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

			Dt_Info.fCurLoad = Pro_Info.fLoadList[i];
			Dt_Info.fLoadValue = Dt_Info.fCurLoad;
			Dt_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;
			Dt_Info.nTimeGap = 1;
			Dt_Info.fCurYouya = Dt_Info.fCurLoad / 10;
			Dt_Info.fWeiyiAvg = fWeiyi - 1;
			for (int m = 0; m < 8; ++m)
			{
				Dt_Info.fWeiyi[m] = Dt_Info.fWeiyiAvg;
			}
			Dt_Info.fShangZhuangShangBa += 4;
			m_vDataInfo.push_back(Dt_Info);

		}
	}

	Pro_Info.nDataCnt = (int)m_vDataInfo.size();
	m_HZProInfo = Pro_Info;
	m_HZProInfo_Old = Pro_Info;
	m_vDataInfo_Old = m_vDataInfo;

	SetCurveUnit(m_HZProInfo);
	InitCalcData();
}

void CHZData::CreateNewData1_1(NEW_DATA New_Data, HZ_PROJECT_INFO Pro_Info)
{
	m_vLvDingInfo.clear();
	m_vDataInfo.clear();

	DATA_INFO Dt_Info;
	USES_CONVERSION;
	CString strVal(L"");
	float fVal = 0;
	float fLastVal = 0; //上一级位移
	strVal = L"虚拟工程";
	strcpy_s(Pro_Info.chProjectName, sizeof(Pro_Info.chProjectName), W2A(strVal));
// 	CTime ct;
// 	ct = CTime::GetCurrentTime();
// 	strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
// 	strcpy_s(Pro_Info.chTestDate, sizeof(Pro_Info.chTestDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chWeiTuoDate, sizeof(Pro_Info.chWeiTuoDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chShiGongDate, sizeof(Pro_Info.chShiGongDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chUploadDate, sizeof(Pro_Info.chUploadDate), W2A(strVal));
	COleDateTime dtTest; //测试时间
	CString strText(L"");
	strText = Pro_Info.chTestDate;
	dtTest.ParseDateTime(strText);

	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));


	memcpy(Pro_Info.chPileNum, "0001", sizeof(Pro_Info.chPileNum));
	Pro_Info.nMaxLoad = (float)New_Data.nMaxLoad;
	Pro_Info.nFirstLoad = New_Data.nFirstLoadGrade;


	Pro_Info.chXunHuanCnt = New_Data.nXunHuan;
	Pro_Info.nLoadTime = New_Data.nLoadTime;
	Pro_Info.nLoadoffTime = New_Data.nLoadoffTime;
	Pro_Info.nTableGap = New_Data.nTableGap;

	Pro_Info.nYuLoadGrade = New_Data.nLoadGrades;
	if (Pro_Info.nYuLoadGrade < 1)
	{
		Pro_Info.nYuLoadGrade = 1;
	}
	Pro_Info.nLoadGrade = New_Data.nLoadGrades;
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nYuLoadGrade * 1.0));
	Pro_Info.fLoadList[0] = float(Pro_Info.nMaxLoad *  Pro_Info.nFirstLoad / 100.0);
	for (int i = 1; i < Pro_Info.nLoadGrade; ++i)
	{
		Pro_Info.fLoadList[i] = fVal * i + Pro_Info.fLoadList[0];
	}
	Pro_Info.fLoadList[Pro_Info.nLoadGrade - 1] = (float)Pro_Info.nMaxLoad;
	//卸载分级
	Pro_Info.nLoadoffGrade = New_Data.nLoadoffGrades = 2;
	fVal = (float)(Pro_Info.nMaxLoad / (Pro_Info.nLoadoffGrade * 1.0));
	for (int i = 0; i < Pro_Info.nLoadoffGrade; ++i)
	{
		Pro_Info.fLoadoffList[i] = (float)(Pro_Info.nLoadoffGrade - i - 1) * fVal;
	}

	Pro_Info.fW = 0;
	Pro_Info.fr1 = 1;
	Pro_Info.fLu = 1;
	Pro_Info.fEp = 1000;
	Pro_Info.fAp = 1;

	Pro_Info.nPileDiam = 100;
	Pro_Info.nPileDiamW = 100;
	Pro_Info.fPilelength = 10.00;
	memcpy(Pro_Info.chTestNo, "T0001", sizeof(Pro_Info.chTestNo));
	Pro_Info.chTestType = 0;
	//	Pro_Info.chUnit = 0;
	Pro_Info.chShape = 0;
	Pro_Info.chPileUsed = 0;
	Pro_Info.chRes1[7];
	memcpy(Pro_Info.chJackNum, "0000", sizeof(Pro_Info.chJackNum));
	Pro_Info.nJackCnts = 1;
	Pro_Info.nJackDiam = 10;
	Pro_Info.chJackType = 0;
	Pro_Info.chWeiYiSensorType = 0;
	Pro_Info.chYaLiSensorType = 0;
	Pro_Info.chPlateType = 0;
	memcpy(Pro_Info.chWeiYiSensorNum, "", sizeof(Pro_Info.chWeiYiSensorNum));
	memcpy(Pro_Info.chYaLiSensorNum, "Y0001", sizeof(Pro_Info.chYaLiSensorNum));
	Pro_Info.fPlateArea = 1;
	for (int i = 0; i < 8; i++)
	{
		if (New_Data.bChannelSel[i])
		{
			Pro_Info.chChanelUsed[i] = 1;
			Pro_Info.chChannelSel[i] = 1;
		}
		else
		{
			Pro_Info.chChanelUsed[i] = 0;
			Pro_Info.chChannelSel[i] = 0;
		}

	}

	for (int i = 0; i < 12; ++i)
	{
		Pro_Info.nLoadTimeList[i] = New_Data.nLoadTimeGap[i];
		Pro_Info.nLoadOffTimeList[i] = New_Data.nLoadoffTimeGap[i];
	}
	Pro_Info.nSignCnts = 0;
	int nTimeGap = 5;
	Pro_Info.nDataCnt = nTimeGap * (Pro_Info.nLoadGrade + Pro_Info.nLoadoffGrade);
	//0时就一个值
	Pro_Info.nDataCnt = Pro_Info.nDataCnt - nTimeGap + 1;
	int nCnt = 0;
	int nBenjiId = 0;
	BOOL bBenjiChange = FALSE;
	float fYouya = 0;
	float fWeiyi = 0;
	float fAddVal = 1;		//每级增加位移
	float fMinusVal = 1;		//每级减少位移
	if (New_Data.bMaxWeiyi)
	{
		fAddVal = New_Data.fMaxWeiyi / Pro_Info.nLoadGrade;
		fMinusVal = fAddVal / 2;
		fAddVal = Carry(fAddVal, 2);
		fMinusVal = Carry(fMinusVal, 2);
	}
	float fWeiYiDest = 0;
	for (int i = 0; i < Pro_Info.nDataCnt; ++i)
	{
		if (nCnt == nTimeGap)
		{
			nCnt = 0;
			nBenjiId++;
			if (!bBenjiChange && nBenjiId >= Pro_Info.nLoadGrade)
			{
				nBenjiId = 0;
				bBenjiChange = TRUE;
			}
			if (bBenjiChange)
			{
				fYouya -= (float)0.1;
				if (fYouya < 0)
				{
					fYouya = 0;
				}

				fWeiyi -= fMinusVal;
				if (fWeiyi < 0)
				{
					fWeiyi = 0;
				}
			}
			else
			{
				fYouya += (float)0.1;
				fWeiyi += fAddVal;
			}
			fWeiYiDest = fWeiyi;
		}
		if (nCnt == 0)
		{
			fWeiyi = fLastVal;
		}
		else
		{
			fLastVal = fWeiYiDest;
			fWeiyi = fWeiYiDest;
		}


		ZeroMemory(&Dt_Info, sizeof(DATA_INFO));
		Dt_Info.chBeiZhu[0] = '\0';
		ct += 60;
		strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
		strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		Dt_Info.nRecordId = nCnt;
		Dt_Info.nIdx = nBenjiId;
		if (bBenjiChange)
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadoffList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;
			Dt_Info.nTimeGap = /*Pro_Info.nLoadOffTimeList[nCnt]*/1;
		}
		else
		{
			Dt_Info.fCurLoad = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.fLoadValue = Pro_Info.fLoadList[nBenjiId];
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			if (i == 0)
			{
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[nCnt]*/ 0;
			}
			else
			{
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[nCnt]*/ 1;
			}

		}
		Dt_Info.fCurYouya = fYouya;

		Dt_Info.fWeiyiAvg = fWeiyi;
		Dt_Info.fShangZhuangShangBa = fWeiyi;
		for (int m = 0; m < 8; ++m)
		{
			Dt_Info.fWeiyi[m] = fWeiyi;
		}
		nCnt++;
		if (0 == i)
		{
			nCnt = nTimeGap;
			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
		}
		m_vDataInfo.push_back(Dt_Info);
	}

	m_HZProInfo = Pro_Info;
	m_HZProInfo_Old = Pro_Info;
	m_vDataInfo_Old = m_vDataInfo;

	SetCurveUnit(m_HZProInfo);
	InitCalcData();
}


void CHZData::CreateNewData4_3(NEW_DATA New_Data, HZ_PROJECT_INFO Pro_Info)
{
	m_vLvDingInfo.clear();
	m_vDataInfo.clear();

	DATA_INFO Dt_Info;
	ZeroMemory(&Dt_Info, sizeof(DATA_INFO));
	Dt_Info.chBeiZhu[0] = '\0';
	USES_CONVERSION;
	CString strVal(L"");
	float fVal = 0;
	float fLastVal = 0; //上一级位移
	strVal = L"虚拟工程";
	strcpy_s(Pro_Info.chProjectName, sizeof(Pro_Info.chProjectName), W2A(strVal));
	COleDateTime dtTest; //测试时间
	CString strText(L"");
	strText = Pro_Info.chTestDate;
	dtTest.ParseDateTime(strText);

	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));


	memcpy(Pro_Info.chPileNum, "0001", sizeof(Pro_Info.chPileNum));
	Pro_Info.nMaxLoad = (float)New_Data.nMaxLoad;
	Pro_Info.chXunHuanCnt = New_Data.nXunHuan;
	Pro_Info.nChuShiHeZai = New_Data.nFirstLoadGrade;
	Pro_Info.nLoadTime = New_Data.nLoadTime;
	Pro_Info.nLoadoffTime = New_Data.nLoadoffTime;
	Pro_Info.nTableGap = New_Data.nTableGap;

	Pro_Info.fW = 0;
	Pro_Info.fr1 = 1;
	Pro_Info.fLu = 1;
	Pro_Info.fEp = 1000;
	Pro_Info.fAp = 1;

	Pro_Info.nPileDiam = 100;
	Pro_Info.nPileDiamW = 100;
	Pro_Info.fPilelength = 10.00;
	memcpy(Pro_Info.chTestNo, "T0001", sizeof(Pro_Info.chTestNo));
	Pro_Info.chTestType = 0;
	//	Pro_Info.chUnit = 0;
	Pro_Info.chShape = 0;
	Pro_Info.chPileUsed = 0;
	Pro_Info.chRes1[7];
	memcpy(Pro_Info.chJackNum, "0000", sizeof(Pro_Info.chJackNum));
	Pro_Info.nJackCnts = 1;
	Pro_Info.nJackDiam = 10;
	Pro_Info.chJackType = 0;
	Pro_Info.chWeiYiSensorType = 0;
	Pro_Info.chYaLiSensorType = 0;
	Pro_Info.chPlateType = 0;
	memcpy(Pro_Info.chWeiYiSensorNum, "", sizeof(Pro_Info.chWeiYiSensorNum));
	memcpy(Pro_Info.chYaLiSensorNum, "Y0001", sizeof(Pro_Info.chYaLiSensorNum));
	Pro_Info.fPlateArea = 1;
	for (int i = 0; i < 8; i++)
	{
		if (New_Data.bChannelSel[i])
		{
			Pro_Info.chChanelUsed[i] = 1;
			Pro_Info.chChannelSel[i] = 1;
		}
		else
		{
			Pro_Info.chChanelUsed[i] = 0;
			Pro_Info.chChannelSel[i] = 0;
		}

	}

	for (int i = 0; i < 12; ++i)
	{
		Pro_Info.nLoadTimeList[i] = New_Data.nLoadTimeGap[i];
		Pro_Info.nLoadOffTimeList[i] = New_Data.nLoadoffTimeGap[i];
	}
	Pro_Info.nSignCnts = 0;
	int nBenjiId = 0;
	float fWeiyi = 0;
	float fAddVal = 0.3;		//每级增加位移
	float fMinusVal = 0.15;		//每级减少位移
	if (New_Data.bMaxWeiyi)
	{
		fAddVal = New_Data.fMaxWeiyi / (Pro_Info.chXunHuanCnt * 3 * 4);
		fMinusVal = fAddVal / 2;
		fAddVal = Carry(fAddVal, 2);
		fMinusVal = Carry(fMinusVal, 2);
	}
	float nBegnLoad = 0, nEndLoad = 0;
	//初始拉力
	float nInitLoad = Pro_Info.nMaxLoad * Pro_Info.nChuShiHeZai / 100;
	float nGapLoad = Pro_Info.nMaxLoad / 20; //间隔拉力
	float fGapWeiyi = 0.2f;
	int nXunHuanNo = 0; //循环序号
	//根据循环加数据
	for (int i = 0; i < Pro_Info.chXunHuanCnt + 1; ++i)
	{
		if (0 == i)
		{
			Dt_Info.nRecordId = 0;
			Dt_Info.nIdx = 0;

			Dt_Info.fCurLoad = 0;
			Dt_Info.fLoadValue = Dt_Info.fCurLoad;
			Dt_Info.fCurYouya = Dt_Info.fCurLoad * 0.1f;
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[0];

			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

			Dt_Info.fWeiyiAvg = 0;
			for (int m = 0; m < 8; ++m)
			{
				Dt_Info.fWeiyi[m] = fWeiyi;
			}
			Dt_Info.fCurYouya = 0;

			m_vDataInfo.push_back(Dt_Info);
			continue;
		}
		else if (1 == i)
		{
			Dt_Info.nRecordId = 0;
			Dt_Info.nIdx = 1;

			Dt_Info.fCurLoad = nInitLoad;
			Dt_Info.fLoadValue = Dt_Info.fCurLoad;
			Dt_Info.fCurYouya = Dt_Info.fCurLoad * 0.1f;
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			for (int j = 0; j < 4; ++j)
			{
				Dt_Info.nRecordId = j;
				Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[j];
				ct += 60 * Dt_Info.nTimeGap;
				strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
				strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

				fWeiyi += fGapWeiyi + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				Dt_Info.fWeiyiAvg = fWeiyi;
				for (int m = 0; m < 8; ++m)
				{
					Dt_Info.fWeiyi[m] = fWeiyi;
				}

				m_vDataInfo.push_back(Dt_Info);
			}
			nXunHuanNo = i;
			nEndLoad = nInitLoad + nGapLoad * 4 * i;
		}
		else if (i <= 3)
		{
			nXunHuanNo = i;
			nEndLoad = nInitLoad + nGapLoad * 4 * i;
		}
		else{
			nXunHuanNo = 4;
			nEndLoad = nInitLoad + nGapLoad * 4 * 3 + (i - 3) * nGapLoad;
		}

		nBenjiId = 2;
		fGapWeiyi = fAddVal;
		//加载数据
		for (int nX = 0; nX < nXunHuanNo; ++nX)
		{
			int nXCnt = 3;
			if (nX == nXunHuanNo - 1)
			{
				if (i > 9)
				{
					nXCnt = 8;
				}
				else{
					nXCnt = 4;
				}
			}
			if (nX < 2)
			{
				Dt_Info.fCurLoad = nInitLoad + nGapLoad * 4 * (nX + 1);
			}
			else if (nX == nXunHuanNo - 1)
			{
				Dt_Info.fCurLoad = nEndLoad;
			}
			else{
				Dt_Info.fCurLoad = nEndLoad - nGapLoad;
			}
			Dt_Info.nIdx = nBenjiId;
			Dt_Info.fLoadValue = Dt_Info.fCurLoad;
			Dt_Info.fCurYouya = Dt_Info.fCurLoad * 0.1f;
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;

	
			for (int j = 0; j < nXCnt; ++j)
			{
				Dt_Info.nRecordId = j;
				Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[j];
				ct += 60 * Dt_Info.nTimeGap;
				strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
				strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

				fWeiyi += fGapWeiyi + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				Dt_Info.fWeiyiAvg = fWeiyi;
				for (int m = 0; m < 8; ++m)
				{
					Dt_Info.fWeiyi[m] = fWeiyi;
				}

				m_vDataInfo.push_back(Dt_Info);
			}
			nBenjiId++;
		}
		nBenjiId = 0;
		fGapWeiyi = fMinusVal;
		//卸载数据
		for (int nX = nXunHuanNo - 1; nX >= 0; nX--)
		{
			int nXCnt = 3;
			if (nX < 3)
			{
				Dt_Info.fCurLoad = nInitLoad + nGapLoad * 4 * nX ;
			}
			else
			{
				Dt_Info.fCurLoad = nEndLoad - nGapLoad;
			}

			Dt_Info.nIdx = nBenjiId;
			Dt_Info.fLoadValue = Dt_Info.fCurLoad;
			Dt_Info.fCurYouya = Dt_Info.fCurLoad * 0.1f;
			Dt_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;

			for (int j = 0; j < nXCnt; ++j)
			{
				Dt_Info.nRecordId = j;
				Dt_Info.nTimeGap = Pro_Info.nLoadOffTimeList[j];
				ct += 60 * Dt_Info.nTimeGap;
				strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
				strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

				fWeiyi -= fGapWeiyi + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				Dt_Info.fWeiyiAvg = fWeiyi;
				for (int m = 0; m < 8; ++m)
				{
					Dt_Info.fWeiyi[m] = fWeiyi;
				}

				m_vDataInfo.push_back(Dt_Info);
			}
			nBenjiId++;
		}
	}
	Pro_Info.nDataCnt = (int)m_vDataInfo.size();
	m_HZProInfo = Pro_Info;
	m_HZProInfo_Old = Pro_Info;
	m_vDataInfo_Old = m_vDataInfo;

	SetCurveUnit(m_HZProInfo);
	InitCalcData();
}

void CHZData::CreateNewData1(NEW_DATA New_Data, HZ_PROJECT_INFO Pro_Info)
{
	m_vLvDingInfo.clear();
	m_vDataInfo.clear();

	DATA_INFO Dt_Info;
	ZeroMemory(&Dt_Info, sizeof(DATA_INFO));
	Dt_Info.chBeiZhu[0] = '\0';
	USES_CONVERSION;
	CString strVal(L"");
	float fVal = 0;
	float fLastVal = 0; //上一级位移
	strVal = L"虚拟工程";
	strcpy_s(Pro_Info.chProjectName, sizeof(Pro_Info.chProjectName), W2A(strVal));
// 	CTime ct;
// 	ct = CTime::GetCurrentTime();
// 	strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
// 	strcpy_s(Pro_Info.chTestDate, sizeof(Pro_Info.chTestDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chWeiTuoDate, sizeof(Pro_Info.chWeiTuoDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chShiGongDate, sizeof(Pro_Info.chShiGongDate), W2A(strVal));
// 	strcpy_s(Pro_Info.chUploadDate, sizeof(Pro_Info.chUploadDate), W2A(strVal));
	COleDateTime dtTest; //测试时间
	CString strText(L"");
	strText = Pro_Info.chTestDate;
	dtTest.ParseDateTime(strText);

	SYSTEMTIME systime;
	VariantTimeToSystemTime(dtTest, &systime);
	CTime ct(systime);
	strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));


	memcpy(Pro_Info.chPileNum, "0001", sizeof(Pro_Info.chPileNum));
	Pro_Info.nMaxLoad = (float)New_Data.nMaxLoad;
	Pro_Info.chXunHuanCnt = New_Data.nXunHuan;
	Pro_Info.nChuShiHeZai = New_Data.nFirstLoadGrade;
	Pro_Info.nLoadTime = New_Data.nLoadTime;
	Pro_Info.nLoadoffTime = New_Data.nLoadoffTime;
	Pro_Info.nTableGap = New_Data.nTableGap;

	Pro_Info.fW = 0;
	Pro_Info.fr1 = 1;
	Pro_Info.fLu = 1;
	Pro_Info.fEp = 1000;
	Pro_Info.fAp = 1;

	Pro_Info.nPileDiam = 100;
	Pro_Info.nPileDiamW = 100;
	Pro_Info.fPilelength = 10.00;
	memcpy(Pro_Info.chTestNo, "T0001", sizeof(Pro_Info.chTestNo));
	Pro_Info.chTestType = 0;
//	Pro_Info.chUnit = 0;
	Pro_Info.chShape = 0;
	Pro_Info.chPileUsed = 0;
	Pro_Info.chRes1[7];
	memcpy(Pro_Info.chJackNum, "0000", sizeof(Pro_Info.chJackNum));
	Pro_Info.nJackCnts = 1;
	Pro_Info.nJackDiam = 10;
	Pro_Info.chJackType = 0;
	Pro_Info.chWeiYiSensorType = 0;
	Pro_Info.chYaLiSensorType = 0;
	Pro_Info.chPlateType = 0;
	memcpy(Pro_Info.chWeiYiSensorNum, "", sizeof(Pro_Info.chWeiYiSensorNum));
	memcpy(Pro_Info.chYaLiSensorNum, "Y0001", sizeof(Pro_Info.chYaLiSensorNum));
	Pro_Info.fPlateArea = 1;
	for (int i = 0; i < 8; i++)
	{
		if (New_Data.bChannelSel[i])
		{
			Pro_Info.chChanelUsed[i] = 1;
			Pro_Info.chChannelSel[i] = 1;
		}
		else
		{
			Pro_Info.chChanelUsed[i] = 0;
			Pro_Info.chChannelSel[i] = 0;
		}

	}

	for (int i = 0; i < 12; ++i)
	{
		Pro_Info.nLoadTimeList[i] = New_Data.nLoadTimeGap[i];
		Pro_Info.nLoadOffTimeList[i] = New_Data.nLoadoffTimeGap[i];
	}
	Pro_Info.nSignCnts = 0;
	int nBenjiId = 0;
	float fWeiyi = 0;
	float fAddVal = 0.3;		//每级增加位移
	float fMinusVal = 0.15;		//每级减少位移
	if (New_Data.bMaxWeiyi)
	{
		fAddVal = New_Data.fMaxWeiyi / (Pro_Info.chXunHuanCnt * 3 * 4);
		fMinusVal = fAddVal / 2;
		fAddVal = Carry(fAddVal, 2);
		fMinusVal = Carry(fMinusVal, 2);
	}
	float nBegnLoad = 0, nEndLoad = 0;
	//初始拉力
	float nInitLoad = Pro_Info.nMaxLoad * Pro_Info.nChuShiHeZai / 100;
	float nGapLoad = Pro_Info.nMaxLoad / 10; //间隔拉力
	float fGapWeiyi = 0.2f;
	//根据循环加数据
	for (int i = 0; i < Pro_Info.chXunHuanCnt + 1; ++i)
	{
		if (0 == i)
		{
			Dt_Info.nRecordId = 0;
			Dt_Info.nIdx = 0;

			Dt_Info.fCurLoad = 0;
			Dt_Info.fLoadValue = 0;
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
			Dt_Info.nTimeGap = Pro_Info.nLoadTimeList[0];

			strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
			strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

			Dt_Info.fWeiyiAvg = 0;
			for (int m = 0; m < 8; ++m)
			{
				Dt_Info.fWeiyi[m] = fWeiyi;
			}
			Dt_Info.fCurYouya = 0;

			m_vDataInfo.push_back(Dt_Info);
			continue;
		}
		else if (1 == i)
		{
			nBegnLoad = nInitLoad;
			nEndLoad = nBegnLoad + nGapLoad;
		}
		else if (2 == i)
		{
			nBegnLoad = nInitLoad;
			nEndLoad = nBegnLoad + nGapLoad * 1;
		}
		else if (3 == i)
		{
			nBegnLoad = nInitLoad + nGapLoad * 2;
			nEndLoad = nBegnLoad + nGapLoad * 3;
		}
		else
		{
			nBegnLoad = nInitLoad + nGapLoad * 4;
			nEndLoad = nBegnLoad + nGapLoad * 3;
		}

		nBenjiId = 1;
		fGapWeiyi = fAddVal;
		//加载数据
		for (float nL = nBegnLoad; nL <= nEndLoad; nL += nGapLoad)
		{
			Dt_Info.nIdx = nBenjiId;
			Dt_Info.fCurLoad = nL;
			Dt_Info.fLoadValue = nL;
			Dt_Info.fCurYouya = nL * 0.1f;
			Dt_Info.nJiaZaiOrXieZai = LOAD_VALUE;
	
			for (int j = 0; j < 4; ++j)
			{
				Dt_Info.nRecordId = j;
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[j]*/1;
				ct += 60;
				strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
				strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));

				fWeiyi += fGapWeiyi + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				Dt_Info.fWeiyiAvg = fWeiyi;
				for (int m = 0; m < 8; ++m)
				{
					Dt_Info.fWeiyi[m] = fWeiyi;
				}

				m_vDataInfo.push_back(Dt_Info);
			}	
			nBenjiId++;
		}

		nBenjiId = 0;
		int nLoadGap = 1;
		if (i >= 3)
		{
			nLoadGap = 2;
		}
		fGapWeiyi = fMinusVal;
		//卸载数据
		for (float nL = nEndLoad - nGapLoad; nL >= nInitLoad; nL -= (nGapLoad * nLoadGap))
		{
			Dt_Info.nIdx = nBenjiId;
			Dt_Info.fCurLoad = nL;
			Dt_Info.fLoadValue = nL;
			Dt_Info.fCurYouya = nL * 0.1f;
			Dt_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;

			for (int j = 0; j < 4; ++j)
			{
				Dt_Info.nRecordId = j;
				Dt_Info.nTimeGap = /*Pro_Info.nLoadTimeList[j]*/1;
				ct += 60;
				strVal = ct.Format(L"%Y-%m-%d %H:%M:%S");
				strcpy_s(Dt_Info.chRecordTime, sizeof(Pro_Info.chTestDate), W2A(strVal));
	
				fWeiyi -= fGapWeiyi + GetRandVal(RAND_MIN_VAL, RAND_MAX_VAL) * 0.01;
				Dt_Info.fWeiyiAvg = fWeiyi;
				for (int m = 0; m < 8; ++m)
				{
					Dt_Info.fWeiyi[m] = fWeiyi;
				}

				m_vDataInfo.push_back(Dt_Info);
			}
			nBenjiId++;
		}
	}
	Pro_Info.nDataCnt = (int)m_vDataInfo.size();
	m_HZProInfo = Pro_Info;
	m_HZProInfo_Old = Pro_Info;
	m_vDataInfo_Old = m_vDataInfo;

	SetCurveUnit(m_HZProInfo);
	InitCalcData();
}

//根据规范获取数据类型
DATA_TYPE CHZData::GetDataType(int nGuifanType, int nGuifan)
{
	return (DATA_TYPE)m_standard.GetDataType(nGuifanType, nGuifan);
// 	DATA_TYPE dataType = DATA_0;
// 	if ((nGuifanType == 0 && nGuifan == 4) ||	   //土层锚杆基本(GB 50007-2011)
// 		(nGuifanType == 0 && nGuifan == 9) ||		//岩土锚杆基本试验(GB 50086-2015)
// 		(nGuifanType == 0 && nGuifan == 11) ||		//岩土锚杆验收多循环(GB 50086-2015)
// 		(nGuifanType == 0 && nGuifan == 12) ||		//锚杆基本试验(GB 50330-2013)
// 		(nGuifanType == 1 && nGuifan == 8)	||		//锚杆基本(JGJ 120 - 2012)
// 		(nGuifanType == 4 && nGuifan == 1)	||		//锚杆基本试验(CECS 22:2005)
// 		(nGuifanType == 4 && nGuifan == 2)			//锚杆验收试验(CECS 22:2005)
// 		)
// 	{
// 		//锚杆试验
// 		dataType = DATA_1;
// 	}
// 	else if ((nGuifanType == 1 && nGuifan == 9) ||			//锚杆验收(JGJ 120 - 2012)
// 		(nGuifanType == 1 && nGuifan == 17) ||				//锚杆基本单循环(JGJ/T 401-2017)
// 		(nGuifanType == 1 && nGuifan == 18) ||				//锚杆验收单循环(JGJ/T 401-2017)
// 		(nGuifanType == 1 && nGuifan == 19) ||				//锚杆验收多循环(JGJ/T 401-2017)
// 		(nGuifanType == 1 && nGuifan == 20) ||				//锚杆验收多循环(JGJ/T 401-2017)
// 		(nGuifanType == 0 && nGuifan == 5) ||				//土层锚杆验收(GB50007-2011)
// 		(nGuifanType == 0 && nGuifan == 13) ||				//锚杆验收试验(GB 50330-2013)
// 		(nGuifanType == 0 && nGuifan == 10)					//岩土锚杆验收单循环(GB 50086-2015)
// 		)
// 	{
// 		//锚杆试验
// 		dataType = DATA_1;
// 	}
// 	else if ((nGuifanType == 1 && nGuifan == 6)||	//水平多循环(JGJ 106-2014)
// 		(nGuifanType == 1 && nGuifan == 25) 	//水平多循环JTG/T 3512-2020)
// 		)
// 	{
// 		dataType = DATA_2;
// 	}
// 	else if (nGuifanType == 1 && nGuifan == 7) //行标自平衡(JGJ/T 403-2017)
// 	{
// 		dataType = DATA_3;
// 	}
// 	else
// 	{
// 		dataType = DATA_0;
// 	}
// 	return dataType;
}

void CHZData::SetCurveUnit(HZ_PROJECT_INFO &ProInfo)
{
	//设置试验类型
	SetTestType(ProInfo);

	m_standard.GetCurCurveInfo(ProInfo.chStandardType, ProInfo.chStandard, ProInfo.chUnit);

// 	if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 0) ||		//国标慢速(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 1) ||		//国标岩基(GB 50007-2011)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 13) ||	//行标复合地基(JGJ 340-2015)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 14) ||	//行标岩基载荷(JGJ 340-2015)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 15) 		//行标地基土平板(JGJ 340-2015)
// 		)		
// 	{
// 		//单桩竖向抗压
// 		if (ProInfo.chUnit == 1)
// 		{
// 			g_strCurveTitle[0] = L"P-s曲线";
// 			g_strCurveTitle[1] = L"s-lgP曲线";
// 			g_strCurveTitle[2] = L"s-lgt曲线";
// 
// 			g_strCurveUnitX[0] = L"P(kPa)";
// 			g_strCurveUnitX[1] = L"P(kPa)";
// 			g_strCurveUnitX[2] = L"t(min)";
// 		}
// 		else
// 		{
// 			g_strCurveTitle[0] = L"Q-s曲线";
// 			g_strCurveTitle[1] = L"s-lgQ曲线";
// 			g_strCurveTitle[2] = L"s-lgt曲线";
// 
// 			g_strCurveUnitX[0] = L"Q(kN)";
// 			g_strCurveUnitX[1] = L"Q(kN)";
// 			g_strCurveUnitX[2] = L"t(min)";
// 		}	
// 
// 		g_strTableTitle[0] = L"数据汇总表";
// 		g_strTableTitle[1] = L"加载详情表";
// 		g_strTableTitle[2] = L"卸载详情表";
// 		g_strTableTitle[3] = L"原始记录表";
// 
// 		g_strCurveUnitY[0] = L"s(mm)";
// 		g_strCurveUnitY[1] = L"s(mm)";
// 		g_strCurveUnitY[2] = L"s(mm)";
// 
// 		g_bAllowChangeUnit = TRUE;
// 	
// 		//数据类型 曲线和表个数
// 		g_DataType = DATA_0;
// 		g_nTableCnt = 4;
// 		g_nCurveCnt = 3;
// 	}
// 	else if ((ProInfo.chStandardType == 1 && ProInfo.chStandard == 2) ||	//行标抗拔(JGJ 106-2014)
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 2) ||			//铁路工程竖向抗拔试验(TB10218-2019)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 21) ||		//锚杆分级载荷基本试验(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 22) ||		//锚杆分级载荷验收试验(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 23) ||		//土钉抗拔试验(JGJ 120-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 24) ||		//土钉抗拔极限试验(JGJ 120-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 16)			//铁路工程竖向抗拔试验(TB10218-2019)
// 		)			
// 	{
// 		//单桩竖向抗拔
// 		//数据类型 曲线和表个数
// 		g_DataType = DATA_0;
// 		g_nTableCnt = 4;
// 		g_nCurveCnt = 3;
// 
// 		g_strCurveTitle[0] = L"U-δ曲线";
// 		g_strCurveTitle[1] = L"δ-lgU曲线";
// 		g_strCurveTitle[2] = L"δ-lgt曲线";
// 
// 		g_strTableTitle[0] = L"数据汇总表";
// 		g_strTableTitle[1] = L"加载详情表";
// 		g_strTableTitle[2] = L"卸载详情表";
// 		g_strTableTitle[3] = L"原始记录表";
// 
// 		g_strCurveUnitX[0] = L"U(kN)";
// 		g_strCurveUnitX[1] = L"U(kN)";
// 		g_strCurveUnitX[2] = L"t(min)";
// 
// 		g_strCurveUnitY[0] = L"δ(mm)";
// 		g_strCurveUnitY[1] = L"δ(mm)";
// 		g_strCurveUnitY[2] = L"δ(mm)";
// 
// 		g_bAllowChangeUnit = FALSE;
// 	}
// 	else if ((ProInfo.chStandardType == 1 && ProInfo.chStandard == 0) ||	//行标快速(JGJ 106-2014)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 1) ||			//行标慢速(JGJ 106-2014)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 3) ||			//岩石锚杆(GB 50007-2011)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 10) ||		//行标竖向增强体(JGJ 340 - 2015)	
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 12) ||		//行标慢速(JTG/T 3512-2020)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 11) ||		//载体单桩慢速试验(JGJ/T 135-2018)
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 0) ||			//铁路工程竖向抗压慢速试验(TB10218-2019)
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 1) ||			//铁路工程复合地基(TB10106-2010)
// 		(ProInfo.chStandardType == 3 && ProInfo.chStandard == 0) ||			//水运工程静载荷快速试验(JTS 237-2017)
// 		(ProInfo.chStandardType == 3 && ProInfo.chStandard == 1) 			//水运工程静载荷慢速试验(JTS 237-2017)
// 		)  
// 	{
// 		//锚杆试验
// 		//数据类型 曲线和表个数
// 		g_DataType = DATA_0;
// 		g_nTableCnt = 4;
// 		g_nCurveCnt = 3;
// 
// 		g_strCurveTitle[0] = L"Q-s曲线";
// 		g_strCurveTitle[1] = L"s-lgQ曲线";
// 		g_strCurveTitle[2] = L"s-lgt曲线";
// 
// 		g_strTableTitle[0] = L"数据汇总表";
// 		g_strTableTitle[1] = L"加载详情表";
// 		g_strTableTitle[2] = L"卸载详情表";
// 		g_strTableTitle[3] = L"原始记录表";
// 
// 		g_strCurveUnitX[0] = L"Q(kN)";
// 		g_strCurveUnitX[1] = L"Q(kN)";
// 		g_strCurveUnitX[2] = L"t(min)";
// 
// 		g_strCurveUnitY[0] = L"s(mm)";
// 		g_strCurveUnitY[1] = L"s(mm)";
// 		g_strCurveUnitY[2] = L"s(mm)";
// 
// 		ProInfo.chUnit = 0;
// 		g_bAllowChangeUnit = FALSE;
// 	}
// 	else if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 6) ||	//岩体原位测试(GB 50021-2001)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 7) ||			//土体原位测试(GB 50021-2001)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 8) ||			//国标平板(GB/T 50123-2019)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 3) ||			//行标复合(JGJ 79-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 4) ||			//处理后地基(JGJ 79-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 5) ||			//复合地基增强体(JGJ 79-2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 0) ||			//浅层平板试验(DB13(J) 148 - 2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 1) ||			//深层平板试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 2) ||			//复合地基(DB13(J) 148 - 2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 3) ||			//岩基载荷试验(DB13(J) 148 - 2012)	
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 0) ||			//浅层平板(JTG 3363-2019)
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 1) ||			//深层平板(JTG 3363-2019)
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 2) 			//岩基载荷试验(JTG 3363-2019)
// 		)			
// 	{
// 		//地方规范
// 		//数据类型 曲线和表个数
// 		g_DataType = DATA_0;
// 		g_nTableCnt = 4;
// 		g_nCurveCnt = 3;
// 
// 		g_strCurveTitle[0] = L"P-s曲线";
// 		g_strCurveTitle[1] = L"s-lgP曲线";
// 		g_strCurveTitle[2] = L"s-lgt曲线";
// 
// 		g_strTableTitle[0] = L"数据汇总表";
// 		g_strTableTitle[1] = L"加载详情表";
// 		g_strTableTitle[2] = L"卸载详情表";
// 		g_strTableTitle[3] = L"原始记录表";
// 
// 		g_strCurveUnitX[0] = L"P(kPa)";
// 		g_strCurveUnitX[1] = L"P(kPa)";
// 		g_strCurveUnitX[2] = L"t(min)";
// 
// 		g_strCurveUnitY[0] = L"s(mm)";
// 		g_strCurveUnitY[1] = L"s(mm)";
// 		g_strCurveUnitY[2] = L"s(mm)";
// 
// 		g_bAllowChangeUnit = FALSE;
// 		ProInfo.chUnit = 1;
// 	}
// 	else if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 4) ||	//土层锚杆基本(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 9) ||			//岩土锚杆基本试验(GB 50086-2015)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 11)|| 		//岩土锚杆验收多循环(GB 50086-2015)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 12) || 		//锚杆基本试验(GB 50330-2013)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 8) ||			//锚杆基本(JGJ 120 - 2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 19) ||		//锚杆基本多循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 20) ||		//锚杆验收多循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 4 && ProInfo.chStandard == 1) 			//锚锚杆基本试验(CECS 22:2005)
// 	
// 		)
// 	{
// 		//锚杆试验
// 		//数据类型 曲线和表个数
// 		g_DataType = DATA_1;
// 		g_nTableCnt = 3;
// 		g_nCurveCnt = 2;
// 
// 		g_strCurveTitle[0] = L"F-s曲线";
// 		g_strCurveTitle[1] = L"Se-F-Sp曲线";
// 
// 		g_strTableTitle[0] = L"数据汇总表";
// 		g_strTableTitle[1] = L"测试详情表";
// 		g_strTableTitle[2] = L"原始记录表";
// 
// 		g_strCurveUnitX[0] = L"s(mm)";
// 		g_strCurveUnitX[1] = L"Se(mm)";
// 		g_strCurveUnitX[2] = L"Sp(mm)";
// 
// 		g_strCurveUnitY[0] = L"F(kN)";
// 		ProInfo.chUnit = 0;
// 		g_bAllowChangeUnit = FALSE;
// 	}
// 	else if ((ProInfo.chStandardType == 1 && ProInfo.chStandard == 9) ||			//锚杆验收(JGJ 120 - 2012)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 5) ||					//土层锚杆验收(GB50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 10)||					//岩土锚杆验收单循环(GB 50086-2015)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 13) ||				//锚杆验收试验(GB 50330-2013)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 17) ||				//锚杆基本单循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 18) ||				//锚杆验收单循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 4 && ProInfo.chStandard == 2)	   		        //锚杆验收试验(CECS 22:2005)
// 		)
// 	{
// 		//数据类型 曲线和表个数
// 		//锚杆试验
// 		g_DataType = DATA_1;
// 		g_nTableCnt = 3;
// 		g_nCurveCnt = 1;
// 
// 		g_strCurveTitle[0] = L"F-s曲线";
// 
// 		g_strTableTitle[0] = L"数据汇总表";
// 		g_strTableTitle[1] = L"测试详情表";
// 		g_strTableTitle[2] = L"原始记录表";
// 
// 		g_strCurveUnitX[0] = L"s(mm)";
// 		g_strCurveUnitY[0] = L"F(kN)";
// 		ProInfo.chUnit = 0;
// 		g_bAllowChangeUnit = FALSE;
// 	}
// 	else if ((ProInfo.chStandardType == 1 && ProInfo.chStandard == 6) ||	//水平多循环(JGJ 106-2014)	
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 25) 	//水平多循环JTG/T 3512-2020)
// 		) 
// 	{
// 		//水平多循环试验
// 		//数据类型 曲线和表个数
// 		g_DataType = DATA_2;
// 		g_nTableCnt = 3;
// 		g_nCurveCnt = 2;
// 
// 		g_strCurveTitle[0] = L"H-t-Y0 曲线";
// 		g_strCurveTitle[1] = L"H-∆Y0/∆H 曲线";
// 
// 		g_strTableTitle[0] = L"数据记录表";
// 		g_strTableTitle[1] = L"加载详测表";
// 		g_strTableTitle[2] = L"原始记录表";
// 
// 		g_strCurveUnitX[0] = L"t(h)";
// 		g_strCurveUnitX[1] = L"H(kN)";
// 		g_strCurveUnitX[2] = L"H(kN)";
// 
// 		g_strCurveUnitY[0] = L"Y0(mm)";
// 		g_strCurveUnitY[1] = L"∆Y0/∆H(mm/kN)";
// 
// 		g_bAllowChangeUnit = FALSE;
// 	}
// 	else if (ProInfo.chStandardType == 1 && ProInfo.chStandard == 7) //行标自平衡(JGJ/T 403-2017)
// 	{
// 		g_DataType = DATA_3;
// 
// 		//单桩竖向抗压
// 		if (ProInfo.chUnit == 1)
// 		{
// 			g_strCurveTitle[0] = L"P-s曲线";
// 			g_strCurveTitle[1] = L"s-lgP曲线";
// 			g_strCurveTitle[2] = L"s-lgt曲线";
// 			g_strCurveTitle[3] = L"P-s等效曲线";
// 
// 			g_strCurveUnitX[0] = L"P(kPa)";
// 			g_strCurveUnitX[1] = L"P(kPa)";
// 			g_strCurveUnitX[2] = L"t(min)";
// 			g_strCurveUnitX[3] = L"P(kPa)";
// 		}
// 		else
// 		{
// 			g_strCurveTitle[0] = L"Q-s曲线";
// 			g_strCurveTitle[1] = L"s-lgQ曲线";
// 			g_strCurveTitle[2] = L"s-lgt曲线";
// 			g_strCurveTitle[3] = L"Q-s等效曲线";
// 
// 			g_strCurveUnitX[0] = L"Q(kN)";
// 			g_strCurveUnitX[1] = L"Q(kN)";
// 			g_strCurveUnitX[2] = L"t(min)";
// 			g_strCurveUnitX[3] = L"Q(kN)";
// 		}
// 
// 		g_strTableTitle[0] = L"数据汇总表";
// 		g_strTableTitle[1] = L"加载详情表";
// 		g_strTableTitle[2] = L"卸载详情表";
// 		g_strTableTitle[3] = L"等效数据汇总";
// 		g_strTableTitle[4] = L"原始记录表";
// 
// 		g_strCurveUnitY[0] = L"s(mm)";
// 		g_strCurveUnitY[1] = L"δ(mm)";
// 
// 		g_bAllowChangeUnit = TRUE;
// 
// 		//数据类型 曲线和表个数
// 		g_nTableCnt = 5;
// 		g_nCurveCnt = 4;
// 	}
// 	else //默认Data_0
// 	{
// 		//单桩竖向抗压
// 		if (ProInfo.chUnit == 1)
// 		{
// 			g_strCurveTitle[0] = L"P-s曲线";
// 			g_strCurveTitle[1] = L"s-lgP曲线";
// 			g_strCurveTitle[2] = L"s-lgt曲线";
// 
// 			g_strCurveUnitX[0] = L"P(kPa)";
// 			g_strCurveUnitX[1] = L"P(kPa)";
// 			g_strCurveUnitX[2] = L"t(min)";
// 		}
// 		else
// 		{
// 			g_strCurveTitle[0] = L"Q-s曲线";
// 			g_strCurveTitle[1] = L"s-lgQ曲线";
// 			g_strCurveTitle[2] = L"s-lgt曲线";
// 
// 			g_strCurveUnitX[0] = L"Q(kN)";
// 			g_strCurveUnitX[1] = L"Q(kN)";
// 			g_strCurveUnitX[2] = L"t(min)";
// 		}
// 
// 		g_strTableTitle[0] = L"数据汇总表";
// 		g_strTableTitle[1] = L"加载详情表";
// 		g_strTableTitle[2] = L"卸载详情表";
// 		g_strTableTitle[3] = L"原始记录表";
// 
// 		g_strCurveUnitY[0] = L"s(mm)";
// 		g_strCurveUnitY[1] = L"s(mm)";
// 		g_strCurveUnitY[2] = L"s(mm)";
// 
// 		g_bAllowChangeUnit = TRUE;
// 
// 		//数据类型 曲线和表个数
// 		g_DataType = DATA_0;
// 		g_nTableCnt = 4;
// 		g_nCurveCnt = 3;
// 	}

	SetMaxLoadType(ProInfo);
}
//设置最大荷载类型
void CHZData::SetMaxLoadType(HZ_PROJECT_INFO &ProInfo)
{
	ProInfo.chMaxLoadType = m_standard.GetMaxLoadType(ProInfo.chStandardType, ProInfo.chStandard);
	
// 	ProInfo.chMaxLoadType = 0;
// 	if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 0) ||			//国标慢速(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 3) ||			//岩石锚杆(GB 50007-2011)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 11) ||		//载体单桩慢速试验(JGJ/T 135-2018)
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 1) ||			//铁路工程复合地基(TB10106-2010)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 0) ||			//行标快速(JGJ 106-2014)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 1) ||			//行标慢速(JGJ 106-2014)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 2) ||			//行标抗拔(JGJ 106 - 2014)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 7) ||			//行标自平衡(JGJ/T 403-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 10) || 		//行标竖向增强体(JGJ 340-2015)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 12) ||		//行标慢速(JTG/T 3512-2020)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 16) ||		//行标抗拔(JTG/T 3512-2020)
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 0) ||			//铁路工程竖向抗压慢速试验(TB10218-2019)
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 2) ||			//铁路工程竖向抗拔试验(TB10218-2019)
// 		(ProInfo.chStandardType == 3 && ProInfo.chStandard == 0) ||			//水运工程静载荷快速试验(JTS 237-2017)
// 		(ProInfo.chStandardType == 3 && ProInfo.chStandard == 1) ||			//水运工程静载荷慢速试验(JTS 237-2017)
// 		(ProInfo.chStandardType == 4 && ProInfo.chStandard == 0) ||			//自定义
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 4) ||			//慢速试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 5) ||			//快速试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 6) ||			//抗拔试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 21) ||		//锚杆分级载荷基本试验(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 22) ||		//锚杆分级载荷验收试验(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 23) ||		//土钉抗拔试验(JGJ 120-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 24) ||		//土钉抗拔极限试验(JGJ 120-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 25) ||		//水平多循环JTG/T 3512-2020)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 6)			//水平多循环(JGJ 106-2014)
// 		)
// 	{
// 		ProInfo.chMaxLoadType = 0;  //最大荷载（kN）
// 	}
// 	else if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 1) ||	//国标岩基(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 6) ||			//岩体原位测试(GB 50021-2001)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 7) ||			//土体原位测试(GB 50021-2001)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 2) ||			//岩基载荷试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 2) ||			//国标平板(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 8) ||			//国标平板(GB/T 50123-2019)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 1) ||			//深层平板试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 1) ||			//深层平板(JTG 3363-2019)
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 2) ||			//岩基载荷试验(JTG 3363-2019)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 3) ||			//行标复合(JGJ 79-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 4) ||			//处理后地基(JGJ 79-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 5) ||			//复合地基增强体(JGJ 79-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 13) ||		//行标复合地基(JGJ 340-2015)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 15) ||		//行标地基土平板(JGJ 340-2015)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 0) ||			//浅层平板试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 3) ||			//复合地基(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 0) ||			//浅层平板(JTG 3363-2019)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 14) 			//行标岩基载荷(JGJ 340-2015)
// 		)
// 	{
// 		ProInfo.chMaxLoadType = 1;	//最大荷载（kPa）
// 	}
// 	else if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 4) ||	//土层锚杆基本(GB 50007-2011)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 8) ||			//锚杆基本(JGJ 120-2012)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 9) ||			//岩土锚杆基本试验(GB 50086-2015)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 9) ||			//锚杆验收(JGJ 120-2012)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 11)||			//岩土锚杆验收多循环(GB 50086-2015)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 10)||			//岩土锚杆验收单循环(GB 50086-2015)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 5) ||			//土层锚杆验收(GB50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 12) ||		//锚杆基本试验(GB 50330-2013)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 13) ||		//锚杆验收试验(GB 50330-2013)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 17) ||		//锚杆基本单循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 18) ||		//锚杆验收单循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 19) ||		//锚杆基本多循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 20) ||		//锚杆验收多循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 4 && ProInfo.chStandard == 1) ||			//锚锚杆基本试验(CECS 22:2005)
// 		(ProInfo.chStandardType == 4 && ProInfo.chStandard == 2)			//锚杆验收试验(CECS 22:2005)
// 		)
// 	{
// 		ProInfo.chMaxLoadType = 2;	//最大拉力（kN）
// 	}
}
//设置试验类型
void CHZData::SetTestType(HZ_PROJECT_INFO &ProInfo)
{
	ProInfo.chTestType = m_standard.GetTestType(ProInfo.chStandardType, ProInfo.chStandard);

// 	if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 0) ||		//国标慢速(GB 50007-2011)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 0) ||		//行标快速(JGJ 106-2014)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 1) ||		//行标慢速(JGJ 106-2014)	
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 10) ||	//行标竖向增强体(JGJ 340-2015)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 11) ||	//载体单桩慢速试验(JGJ/T 135-2018)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 12) ||	//行标慢速(JTG/T 3512-2020)	
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 0) ||		//铁路工程竖向抗压慢速试验(TB10218-2019)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 4) ||		//慢速试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 5) ||		//快速试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 3 && ProInfo.chStandard == 0) ||		//水运工程静载荷快速试验(JTS 237-2017)
// 		(ProInfo.chStandardType == 3 && ProInfo.chStandard == 1) 		//水运工程静载荷慢速试验(JTS 237-2017)
// 		
// 		)
// 	{
// 		//单桩竖向抗压
// 		ProInfo.chTestType = 0;
// 	}
// 	else if ((ProInfo.chStandardType == 1 && ProInfo.chStandard == 2) ||	//行标抗拔(JGJ 106 - 2014)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 16) ||		//行标抗拔(JGJ 106 - 2014)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 23) ||		//土钉抗拔试验(JGJ 120-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 24) ||		//土钉抗拔极限试验(JGJ 120-2012)
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 2) ||			//铁路工程竖向抗拔试验(TB10218-2019)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 6)			//抗拔试验(DB13(J) 148-2012)
// 		)
// 	{
// 		//单桩竖向抗拔
// 		ProInfo.chTestType = 1;
// 	}
// 	else if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 3) || 	//岩石锚杆(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 4) ||			//土层锚杆基本(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 5) ||			//土层锚杆验收(GB50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 9) || 		//岩土锚杆基本试验(GB 50086-2015)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 10) ||		//岩土锚杆验收单循环(GB 50086-2015)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 11) ||		//岩土锚杆验收多循环(GB 50086-2015)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 12) ||		//锚杆基本试验(GB 50330-2013)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 13) ||		//锚杆验收试验(GB 50330-2013)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 8) ||			//锚杆基本(JGJ 120-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 9) ||			//锚杆验收(JGJ 120-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 17) ||		//锚杆基本单循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 18) ||		//锚杆验收单循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 19) ||		//锚杆基本多循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 20) ||		//锚杆验收多循环(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 21) ||		//锚杆分级载荷基本试验(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 22) ||		//锚杆分级载荷验收试验(JGJ/T 401-2017)
// 		(ProInfo.chStandardType == 4 && ProInfo.chStandard == 1) ||			//锚锚杆基本试验(CECS 22:2005)
// 		(ProInfo.chStandardType == 4 && ProInfo.chStandard == 2)			//锚杆验收试验(CECS 22:2005)
// 		)
// 	{
// 		//锚杆试验
// 		ProInfo.chTestType = 2;
// 	}
// 	else if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 1) ||	//国标岩基(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 6) ||			//岩体原位测试(GB 50021 - 2001)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 7) ||			//土体原位测试(GB 50021-2001)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 3) ||			//行标复合(JGJ 79-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 4) ||			//处理后地基(JGJ 79-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 5) ||			//复合地基增强体(JGJ 79-2012)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 13)||			//行标复合地基(JGJ 340-2015)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 14) ||		//行标岩基载荷(JGJ 340-2015)
// 		(ProInfo.chStandardType == 2 && ProInfo.chStandard == 1) ||			//铁路工程复合地基(TB10106-2010)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 3) ||			//复合地基(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 2) ||			//岩基载荷试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 2) 			//复岩基载荷试验(JTG 3363-2019)
// 		)
// 	{
// 		//复合地基试验
// 		ProInfo.chTestType = 3;
// 	}
// 	else if ((ProInfo.chStandardType == 0 && ProInfo.chStandard == 2) ||	//国标平板(GB 50007-2011)
// 		(ProInfo.chStandardType == 0 && ProInfo.chStandard == 8)||			//国标平板(GB/T 50123-2019)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 15) ||		//行标地基土平板(JGJ 340-2015)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 0) ||			//深层平板试验(DB13(J) 148-2012)
// 		(ProInfo.chStandardType == 5 && ProInfo.chStandard == 1) ||			//深层平板(JTG 3363-2019)
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 0) ||			//浅层平板(JTG 3363-2019)
// 		(ProInfo.chStandardType == 6 && ProInfo.chStandard == 1) 			//深层平板(JTG 3363-2019)
// 		)
// 	{
// 		//平板试验
// 		ProInfo.chTestType = 4;
// 	}
// 	else if ((ProInfo.chStandardType == 1 && ProInfo.chStandard == 6)||		//水平多循环(JGJ 106-2014)
// 		(ProInfo.chStandardType == 1 && ProInfo.chStandard == 25)			//水平多循环JTG/T 3512-2020)
// 		)
// 	{
// 		//单桩水平试验
// 		ProInfo.chTestType = 5;
// 	}
// 	else if ((ProInfo.chStandardType == 1 && ProInfo.chStandard == 7)		//行标自平衡(JGJ/T 403-2017)
// 		)
// 	{
// 		//自平衡试验
// 		ProInfo.chTestType = 6;
// 	}
// 	else
// 	{
// 		//单桩竖向抗压
// 		ProInfo.chTestType = 0;
// 	}
}


BOOL CHZData::SaveFile(CString strFilePath, HZ_PROJECT_INFO Pro_Info, vector<DATA_INFO>	vDataInfo, HZ_PROJECT_INFO Old_Pro_Info, vector<DATA_INFO>	vDataInfo_Old, vector<LVDING_INFO> vLvDingInfo)
{
	if (strFilePath == L"")
	{
		return FALSE;
	}
	//写入文件
	CFile file;
	if (file.Open(strFilePath, CFile::modeCreate | CFile::modeReadWrite
		| CFile::modeNoTruncate))
	{
		file.Seek(0, CFile::begin);
		//写入文件的代号 文件标识
		HZ_VERSION ver;
		memcpy(ver.chSoftFlag, "HC_JZ", 5);
		ver.nFileDaiHao = FILE_DAIHAO;
		ver.nFileVersion = FILE_VERSION;
		file.Write(&ver, sizeof(HZ_VERSION));

		Pro_Info.nDataCnt = (int)vDataInfo.size();
		file.Write(&Pro_Info, sizeof(HZ_PROJECT_INFO));
		for (int i = 0; i < Pro_Info.nDataCnt; ++i)
		{
			file.Write(&vDataInfo[i], sizeof(DATA_INFO));
		}

		Old_Pro_Info.nDataCnt = (int)vDataInfo_Old.size();
		file.Write(&Old_Pro_Info, sizeof(HZ_PROJECT_INFO));
		for (int i = 0; i < Old_Pro_Info.nDataCnt; ++i)
		{
			file.Write(&vDataInfo_Old[i], sizeof(DATA_INFO));
		}

		int nSize = (int)vLvDingInfo.size();
		file.Write(&nSize, sizeof(int));
		for (int i = 0; i < nSize; ++i)
		{
			file.Write(&vLvDingInfo[i], sizeof(LVDING_INFO));
		}

		file.Close();
		return TRUE;
	}
	return FALSE;
}

BOOL CHZData::SaveFile(CString strFilePath)
{
	return SaveFile(strFilePath, m_HZProInfo, m_vDataInfo, m_HZProInfo_Old, m_vDataInfo_Old, m_vLvDingInfo);
}

void CHZData::ClearProject()
{
	ZeroMemory(&m_HZProInfo, sizeof(HZ_PROJECT_INFO));
	vector<DATA_INFO>().swap(m_vDataInfo);
	vector<DATA_INFO>().swap(m_vDataInfo_Old);
	ZeroMemory(&m_HZProInfo_Old, sizeof(HZ_PROJECT_INFO));
	vector<LVDING_INFO>().swap(m_vLvDingInfo);
}

//保存json文件
void CHZData::SaveJsonFile(CString strFilePath)
{
	CJsonAnalysis::m_pWnd->WriteJson(strFilePath, m_HZProInfo, m_vDataInfo, m_vLvDingInfo);
}

//打开jz后缀文件 app端数据文件 返回保存后的数据文件
CString CHZData::OpenJZFile(CString strFilePath)
{
	CString strSavePath(L"");
	if (strFilePath == L"")
	{
		return L"";
	}

	setlocale(LC_CTYPE, "chs");
	CFile file;
	if (file.Open(strFilePath, CFile::modeRead))
	{
		file.Seek(0, CFile::begin);	
		int nLen = int(file.GetLength());
		char *str = new char[nLen + 1];
		file.Read(str, nLen);
		CString strText(L"");
		strText = CharToUnicode(str);
		//strText = (str);
		delete[]str;
		str = NULL;
		file.Close();
		HZ_PROJECT_INFO Pro_Info;
		vector<DATA_INFO>	vDataInfo;
		vector<LVDING_INFO>	vLvDingInfo;
		//js解析
		BOOL bRes = CJsonAnalysis::m_pWnd->GetJsData(strText, Pro_Info, vDataInfo, vLvDingInfo);
		
		if (!bRes)
		{
			return L"";
		}
		strSavePath = strFilePath.Left(strFilePath.GetLength() - 2) + EXT_JZQ;
		if (FileIsExist(strSavePath))
		{
			if (MsgBox(L"同名.jzq文件已经存在，是否覆盖？", L"提示", MB_YESNO | MB_ICONQUESTION) != IDYES)
			{
				CFileDlg dlg(TRUE, L"jzq");
				dlg.m_ofn.lpstrFilter = L"数据文件(*.jzq)\0*.jzq\0\0";
				if (dlg.DoModal() == IDOK)
				{
					strSavePath = dlg.GetPathName();
				}
				else
				{
					return L"";
				}
			}
		}
		//将.jz原始数据文件保存到BK文件夹中
		CString strBKDir = strFilePath;
		int nPos = strBKDir.ReverseFind('\\');
		strBKDir = strBKDir.Left(nPos);
		strBKDir += L"\\BK";
		if (!PathIsDirectory(strBKDir))
		{
			CreateDirectory(strBKDir, 0);
		}
		CString strDirName = strFilePath.Right(strFilePath.GetLength() - nPos);
		MoveFile(strFilePath, strBKDir + strDirName);
//		DeleteFile(strFilePath);
		SaveFile(strSavePath, Pro_Info, vDataInfo, Pro_Info, vDataInfo, vLvDingInfo);

		vector<DATA_INFO>().swap(vDataInfo);
		vector<LVDING_INFO>().swap(vLvDingInfo);
	}
	return strSavePath;
}

BOOL CHZData::OpenFile(CString strFilePath)
{
	if (strFilePath == L"")
	{
		return FALSE;
	}

	CString strExt = strFilePath.Right(3);
	strExt = strExt.MakeLower();
	if (strExt != EXT_JZQ)
	{
		return FALSE;
	}

	CString strVal(L"");
	CFile file;
	if (file.Open(strFilePath, CFile::modeRead))
	{
		file.Seek(0, CFile::begin);
		//写入文件的代号 文件标识
		HZ_VERSION ver;
		file.Read(&ver, sizeof(HZ_VERSION));
		strVal = ver.chSoftFlag;
		strVal = strVal.Left(5);
		//对文件进行判断
		if (ver.nFileDaiHao != FILE_DAIHAO || strVal != SOFT_FLAG)
		{
			file.Close();
			return FALSE;
		}
		//当前版本的文件
		if (ver.nFileVersion == FILE_VERSION)
		{
			ClearProject();
			file.Read(&m_HZProInfo, sizeof(HZ_PROJECT_INFO));

			DATA_INFO DataInfo;
			for (int i = 0; i < m_HZProInfo.nDataCnt; ++i)
			{
				ZeroMemory(&DataInfo, sizeof(DATA_INFO));
				file.Read(&DataInfo, sizeof(DATA_INFO));
				m_vDataInfo.push_back(DataInfo);
			}
			file.Read(&m_HZProInfo_Old, sizeof(HZ_PROJECT_INFO));
			for (int i = 0; i < m_HZProInfo_Old.nDataCnt; ++i)
			{
				ZeroMemory(&DataInfo, sizeof(DATA_INFO));
				file.Read(&DataInfo, sizeof(DATA_INFO));
				m_vDataInfo_Old.push_back(DataInfo);
			}
			int nSize = 0;
			file.Read(&nSize, sizeof(int));
			LVDING_INFO LvDing;
			for (int i = 0; i < nSize; ++i)
			{
				ZeroMemory(&LvDing, sizeof(LVDING_INFO));
				file.Read(&LvDing, sizeof(LVDING_INFO));
				m_vLvDingInfo.push_back(LvDing);
			}
		}
		file.Close();
		SetCurveUnit(m_HZProInfo);
		InitCalcData();
		return TRUE;
	}
	return FALSE;
}

//初始计算所有值
void CHZData::InitCalcData()
{
	ClearVector(m_vLoadData);
	ClearVector(m_vLoadValue);
	ClearVector(m_vLoadOffData);
	ClearVector(m_vLoadoffValue);
	ClearVector(m_vSummaryData);
	ClearVector(m_vvMgXQBData);
	ClearVector(m_vSpLoad);

	if (g_DataType == DATA_1)
	{
		CalcMgXQBData(m_vvMgXQBData);
		CalcMgSummaryDataNew(m_vMgSummaryData);
	}
	else if (g_DataType == DATA_2)
	{
		GetSpJiluData(m_HZProInfo, m_vDataInfo, m_vSpLoad);
		GetSpLoadValue(m_HZProInfo, m_vDataInfo, m_vLoadData, m_vLoadValue);
	}
	else if (g_DataType == DATA_3)
	{
		//获取加载和卸载数据
		GetLoadValue(m_HZProInfo, m_vDataInfo, m_vLoadData, m_vLoadValue, LOAD_VALUE);
		GetLoadValue(m_HZProInfo, m_vDataInfo, m_vLoadOffData, m_vLoadoffValue, LOADOFF_VALUE);
		CalcSummaryDataNew(m_vSummaryData);
	}
	else //默认 g_DataType == DATA_0
	{		
		//获取加载和卸载数据
		GetLoadValue(m_HZProInfo, m_vDataInfo, m_vLoadData, m_vLoadValue, LOAD_VALUE);
		GetLoadValue(m_HZProInfo, m_vDataInfo, m_vLoadOffData, m_vLoadoffValue, LOADOFF_VALUE);
		CalcSummaryDataNew(m_vSummaryData);
	}
}

//重新计算平均值
void CHZData::ReCalcAvgData()
{
	if (!g_bInitData)
	{
		return;
	}
	float fAvg = 0;
	int nCnt = 0;
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		nCnt = 0;
		fAvg = 0;
		for (int n = 0; n < 8; ++n)
		{
			if (m_HZProInfo.chChanelUsed[n] != 0 && m_HZProInfo.chChannelSel[n])
			{
				fAvg += m_vDataInfo[i].fWeiyi[n];
				nCnt++;
			}
		}
		m_vDataInfo[i].fWeiyiAvg = (float)(fAvg / (nCnt * 1.0));
		Carry(m_vDataInfo[i].fWeiyiAvg, 2);
		CheckValue(m_vDataInfo[i].fWeiyiAvg);
	}

	//重新计算所有值
	InitCalcData();
}

//计算出详细表数据
void CHZData::CalcMgXQBData(vector< vector<TABLE_SUMMARY>> &vvMgXQBData)
{
	ClearVector(vvMgXQBData);
	TABLE_SUMMARY sumData;
	ZeroMemory(&sumData, sizeof(sumData));
	vector<TABLE_SUMMARY> vData;

	int nLastGap = 0; 
	float nLastWeiyi = 0;
	int nCurBenji = 0;
	int nJiaZai = 0;
	BOOL bFirst = TRUE;

	int nXunhuan = 0;
	int nRecordCnt = 0; 
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
//		ZeroMemory(&sumData, sizeof(sumData));

		sumData.fLoadVal = m_vDataInfo[i].fLoadValue;
		sumData.nBenJiId = m_vDataInfo[i].nIdx;
		sumData.nJiaZaiOrXieZai = m_vDataInfo[i].nJiaZaiOrXieZai;
		//累计位移
		sumData.fAllDisp = m_vDataInfo[i].fWeiyiAvg;
		sumData.fDispVal = sumData.fAllDisp - nLastWeiyi;
		nLastWeiyi = sumData.fAllDisp;

		if (nXunhuan == 0)
		{
			//本级时间
			if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
			{
				sumData.nTimeGap = m_HZProInfo.nLoadTimeList[nRecordCnt];
			}
			else
			{
				sumData.nTimeGap = m_HZProInfo.nLoadOffTimeList[nRecordCnt];
			}
			sumData.nALlTime = nLastGap + sumData.nTimeGap;

			nLastGap = sumData.nALlTime;
			nLastWeiyi = sumData.fAllDisp;

			vData.push_back(sumData);
			vvMgXQBData.push_back(vData);
			vData.clear();
			nXunhuan++;
		}
		else if (1 == nXunhuan) //初始循环
		{
			if (bFirst)
			{
				nCurBenji = m_vDataInfo[i].nIdx;
				nJiaZai = m_vDataInfo[i].nJiaZaiOrXieZai;
				nRecordCnt = 0;
				//本级时间
				if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
				{
					sumData.nTimeGap = m_HZProInfo.nLoadTimeList[nRecordCnt];
				}
				else
				{
					sumData.nTimeGap = m_HZProInfo.nLoadOffTimeList[nRecordCnt];
				}
				sumData.nALlTime = nLastGap + sumData.nTimeGap;
				nRecordCnt++;

				vData.push_back(sumData);
				bFirst = FALSE;
			}
			else
			{
				//判断当前本级和加载 是不是和上一个一样
				if (nCurBenji == m_vDataInfo[i].nIdx && nJiaZai == m_vDataInfo[i].nJiaZaiOrXieZai)
				{
					//本级时间
					if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
					{
						sumData.nTimeGap += m_HZProInfo.nLoadTimeList[nRecordCnt];
					}
					else
					{
						sumData.nTimeGap += m_HZProInfo.nLoadOffTimeList[nRecordCnt];
					}
					sumData.nALlTime = nLastGap + sumData.nTimeGap;
					nRecordCnt++;

					vData.push_back(sumData);
				}
				else{
					//遇到下一个本级，上一个循环插入vector
					nLastGap = sumData.nALlTime;
					vvMgXQBData.push_back(vData);
					vData.clear();
					nXunhuan++;

					nCurBenji = m_vDataInfo[i].nIdx;
					nJiaZai = m_vDataInfo[i].nJiaZaiOrXieZai;
					//本级时间
					nRecordCnt = 0;
					if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
					{
						sumData.nTimeGap = m_HZProInfo.nLoadTimeList[nRecordCnt];
					}
					else
					{
						sumData.nTimeGap = m_HZProInfo.nLoadOffTimeList[nRecordCnt];
					}
					nRecordCnt++;
					sumData.nALlTime = nLastGap + sumData.nTimeGap;
					vData.push_back(sumData);
				}
			}
		}
		else
		{
			//如果当前加载， 上一个是卸载，则循环+1
			if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE && nJiaZai == LOADOFF_VALUE)
			{
				nLastGap = sumData.nALlTime;
				vvMgXQBData.push_back(vData);
				vData.clear();
				nXunhuan++;

				nCurBenji = m_vDataInfo[i].nIdx;
				nJiaZai = m_vDataInfo[i].nJiaZaiOrXieZai;
				//本级时间
				nRecordCnt = 0;
				if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
				{
					sumData.nTimeGap = m_HZProInfo.nLoadTimeList[nRecordCnt];
				}
				else
				{
					sumData.nTimeGap = m_HZProInfo.nLoadOffTimeList[nRecordCnt];
				}
				nRecordCnt++;
				sumData.nALlTime = nLastGap + sumData.nTimeGap;
				vData.push_back(sumData);
			}
			else 
			{
				if (nCurBenji == m_vDataInfo[i].nIdx && nJiaZai == m_vDataInfo[i].nJiaZaiOrXieZai)
				{
					//本级时间
					if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
					{
						sumData.nTimeGap += m_HZProInfo.nLoadTimeList[nRecordCnt];
					}
					else
					{
						sumData.nTimeGap += m_HZProInfo.nLoadOffTimeList[nRecordCnt];
					}
					sumData.nALlTime = nLastGap + sumData.nTimeGap;
					nRecordCnt++;

					vData.push_back(sumData);
				}
				else{
					//遇到下一个本级，上一个循环插入vector
					nLastGap = sumData.nALlTime;

					nCurBenji = m_vDataInfo[i].nIdx;
					nJiaZai = m_vDataInfo[i].nJiaZaiOrXieZai;
					//本级时间
					nRecordCnt = 0;
					if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
					{
						sumData.nTimeGap = m_HZProInfo.nLoadTimeList[nRecordCnt];
					}
					else
					{
						sumData.nTimeGap = m_HZProInfo.nLoadOffTimeList[nRecordCnt];
					}
					nRecordCnt++;
					sumData.nALlTime = nLastGap + sumData.nTimeGap;
					vData.push_back(sumData);
				}
			}
		}
		if (i == (int)m_vDataInfo.size() - 1)
		{
			vvMgXQBData.push_back(vData);
		}
	}
	ClearVector(vData);
}

void CHZData::CalcMgSummaryDataNew(vector<TABLE_SUMMARY> &vMgSummaryData)
{
	ClearVector(vMgSummaryData);
	TABLE_SUMMARY SumData;
	ZeroMemory(&SumData, sizeof(SumData));
//	vector<TABLE_SUMMARY> vSumData;
	int nId = 0;		//本级所以
	int nLoad = 0;		//加载方式

	int nCnt = 0;		//数据个数

	int nLastGap = 0;		//上次时间间隔
	float nLastWaiyi = 0;	//上次位移
	int nXunHuan = 0;
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (0 == i)
		{
			nId = 0;
//			nLoad = SumData.nJiaZaiOrXieZai;
			nLoad = m_vDataInfo[i].nJiaZaiOrXieZai;
			SumData.nBenJiId = nXunHuan;
		}
		else if (nId == m_vDataInfo[i].nIdx && nLoad == m_vDataInfo[i].nJiaZaiOrXieZai)
		{

		}
		else
		{
			//当本级ID 和 原始所以 不一样时 就插入容器
			nCnt = 0;	
			SumData.fDispVal = SumData.fAllDisp - nLastWaiyi;
			nLastWaiyi = SumData.fAllDisp;

			SumData.nALlTime = nLastGap + SumData.nTimeGap;
			nLastGap = SumData.nALlTime;

			vMgSummaryData.push_back(SumData);
			ZeroMemory(&SumData, sizeof(SumData));

			if (1 == i)
			{
				nXunHuan++;
			}
			else if (nXunHuan == 1 && (nId != m_vDataInfo[i].nIdx || nLoad != m_vDataInfo[i].nJiaZaiOrXieZai))
			{
				nXunHuan++;
			}
			else if (nLoad == LOADOFF_VALUE && m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
			{
				nXunHuan++;
			}
			nId = m_vDataInfo[i].nIdx;
			nLoad = m_vDataInfo[i].nJiaZaiOrXieZai;
		}

		if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
		{
			SumData.nTimeGap += m_HZProInfo.nLoadTimeList[nCnt];
		}
		else
		{
			SumData.nTimeGap += m_HZProInfo.nLoadOffTimeList[nCnt];
		}
		nCnt++;
		SumData.nDataCnt = nCnt;

//		SumData.nBenJiId = m_vDataInfo[i].nIdx;
		SumData.nBenJiId = nXunHuan;
		SumData.fLoadVal = m_vDataInfo[i].fLoadValue;
		SumData.nJiaZaiOrXieZai = m_vDataInfo[i].nJiaZaiOrXieZai;
		SumData.fAllDisp = m_vDataInfo[i].fWeiyiAvg;

		if (i == (int)m_vDataInfo.size() - 1)
		{
			//当本级ID 和 原始所以 不一样时 就插入容器
			SumData.fDispVal = SumData.fAllDisp - nLastWaiyi;
			SumData.nALlTime = nLastGap + SumData.nTimeGap;
			vMgSummaryData.push_back(SumData);
		}
	}
}

//计算出汇总表数据
void CHZData::CalcSummaryDataNew(vector<TABLE_SUMMARY> &vData_Sum)
{
	//统计加载数据
	vData_Sum.clear();
	TABLE_SUMMARY Data;
	int nAllTime = 0;
	float fLastValue = 0;
	float fLastUpVal = 0;
	int nCnt = 0;
	for (int n = 0; n < (int)m_vLoadValue.size(); ++n)
	{
		ZeroMemory(&Data, sizeof(TABLE_SUMMARY));
		Data.nJiaZaiOrXieZai = LOAD_VALUE;
		Data.nBenJiId = n;
		Data.fLoadVal = m_vLoadValue[n];
		nCnt = 0;
		for (int t = 0; t < (int)m_vLoadData.size(); ++t)
		{
			if (!m_vLoadData[t].vExist[n])
			{
				break;
			}
			else
			{
				Data.nTimeGap = m_vLoadData[t].nTime;
				Data.fAllDisp = m_vLoadData[t].vfWeiyi[n];
				Data.fDispVal = Data.fAllDisp - fLastValue;
				CheckValue(Data.fDispVal);

				Data.fUpAllDisp = m_vLoadData[t].vfUpWeiyi[n];
				Data.fUpDispVal = Data.fUpAllDisp - fLastUpVal;
				CheckValue(Data.fUpDispVal);
				
				nCnt++;
			}
		}
		Data.nDataCnt = nCnt;
		nAllTime += Data.nTimeGap;
		Data.nALlTime = nAllTime;
		fLastValue = Data.fAllDisp;
		fLastUpVal = Data.fUpAllDisp;
		vData_Sum.push_back(Data);
	}

	//卸载值
	for (int n = 0; n < (int)m_vLoadoffValue.size(); ++n)
	{
		ZeroMemory(&Data, sizeof(TABLE_SUMMARY));
		Data.nJiaZaiOrXieZai = LOADOFF_VALUE;
		Data.fLoadVal = m_vLoadoffValue[n];
		Data.nBenJiId = n;
		if (n > 0)
		{
			fLastValue = vData_Sum[n - 1 + (int)m_vLoadValue.size()].fAllDisp;
			fLastUpVal = vData_Sum[n - 1 + (int)m_vLoadValue.size()].fUpAllDisp;
		}
		nCnt = 0;
		for (int t = 0; t < (int)m_vLoadOffData.size(); ++t)
		{
			if (!m_vLoadOffData[t].vExist[n])
			{
				break;
			}
			else
			{
				Data.nTimeGap = m_vLoadOffData[t].nTime;
				Data.fAllDisp = m_vLoadOffData[t].vfWeiyi[n];
				Data.fDispVal = Data.fAllDisp - fLastValue;
				CheckValue(Data.fDispVal);

				Data.fUpAllDisp = m_vLoadOffData[t].vfUpWeiyi[n];
				Data.fUpDispVal = Data.fUpAllDisp - fLastUpVal;
				CheckValue(Data.fUpDispVal);
				nCnt++;
			}
		}
		Data.nDataCnt = nCnt;
		nAllTime += Data.nTimeGap;
		Data.nALlTime = nAllTime;
		vData_Sum.push_back(Data);
	}

	CalcZphQQsData();
}

//计算等效数据
void CHZData::CalcZphQQsData()
{
	ClearVector(m_vZphQQsData);
	if (g_DataType != DATA_3)
	{
		return;
	}
	if (m_HZProInfo.fr1 >= -EPSINON && m_HZProInfo.fr1 <= EPSINON)
	{
		m_HZProInfo.fr1 = 1;
	}
	if (m_HZProInfo.fEp >= -EPSINON && m_HZProInfo.fEp <= EPSINON)
	{
		m_HZProInfo.fEp = 1000;
	}
	if (m_HZProInfo.fAp >= -EPSINON && m_HZProInfo.fAp <= EPSINON)
	{
		m_HZProInfo.fAp = 1;
	}

	Zph_QQS QsData;
	float fVal = 0;
	for (int i = 0; i < (int)m_vSummaryData.size(); i++)
	{
		QsData.fLoadVal = (m_vSummaryData[i].fLoadVal - m_HZProInfo.fW) / m_HZProInfo.fr1 + m_vSummaryData[i].fLoadVal;
		QsData.fWeiyi = m_vSummaryData[i].fAllDisp + (QsData.fLoadVal + m_vSummaryData[i].fLoadVal) * m_HZProInfo.fLu / (2 * m_HZProInfo.fEp * m_HZProInfo.fAp);
		QsData.nJiazai = m_vSummaryData[i].nJiaZaiOrXieZai;

		m_vZphQQsData.push_back(QsData);
	}

}

// 获取加载详测表列数 
int CHZData::GetSpLoadTableColCnt(HZ_PROJECT_INFO Pro_Info, vector<DATA_INFO> vDataInfo, vector<float> &vLoadValue)
{
	int nColCnt = 0;
	float fLoadValue = 0;
	ClearVector(vLoadValue);
	BOOL bFirst = TRUE;
	for (int i = 0; i < (int)vDataInfo.size(); ++i)
	{
		if (bFirst)
		{
			fLoadValue = vDataInfo[i].fLoadValue;
			vLoadValue.push_back(fLoadValue);
			nColCnt++;
			bFirst = FALSE;
		}
		else
		{
			if (fLoadValue != vDataInfo[i].fLoadValue)
			{
				fLoadValue = vDataInfo[i].fLoadValue;
				vLoadValue.push_back(fLoadValue);
				nColCnt++;
			}
		}
	}
	return nColCnt;
}

//获取加载详测表列数
int CHZData::GetLoadTableColCnt(HZ_PROJECT_INFO	Pro_Info, vector<DATA_INFO> vDataInfo, vector<float> &vLoadValue, int nDataType)
{
	int nColCnt = 0;
	float fLoadValue = 0;
	ClearVector(vLoadValue);
	BOOL bFirst = TRUE;
	int nNo = 0;
	for (int i = 0; i < (int)vDataInfo.size(); ++i)
	{
		if (nDataType != vDataInfo[i].nJiaZaiOrXieZai)
		{
			continue;
		}
		if (bFirst)
		{
			nNo = vDataInfo[i].nIdx;
			fLoadValue = vDataInfo[i].fLoadValue;
			vLoadValue.push_back(fLoadValue);
			nColCnt++;
			bFirst = FALSE;
		}
		else
		{
			if (fLoadValue != vDataInfo[i].fLoadValue || nNo != vDataInfo[i].nIdx)
			{
				fLoadValue = vDataInfo[i].fLoadValue;
				vLoadValue.push_back(fLoadValue);
				nColCnt++;
				nNo = vDataInfo[i].nIdx;
			}
		}
	}
	return nColCnt;
}

//统计记录数据
void CHZData::GetSpJiluData(HZ_PROJECT_INFO Pro_Info, vector<DATA_INFO> vDataInfo, vector<SP_LOAD> &vSpLoad)
{
	ClearVector(vSpLoad);
	//现获取时间序列
	float fLoadValue = 0; //本级值
	int nSize = (int)vDataInfo.size();
	SP_LOAD Data;
	Data.nXunhuan = 0;
	BOOL bFirst = TRUE;
	float fLoadoffNext = 0.0f;
	for (int i = 0; i < nSize - 1; i++)
	{
		//加载和卸载是需要同时存在 才能计算 且同千牛时
		if (vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE && vDataInfo[i + 1].nJiaZaiOrXieZai == LOADOFF_VALUE
			&& vDataInfo[i].fLoadValue == vDataInfo[i + 1].fLoadValue)
		{
			Data.nNo = i;
			Data.fLoadVal = vDataInfo[i].fLoadValue;
			Data.fCurLoadVal = vDataInfo[i].fCurLoad;
			Data.strTime = GetProInfoTime(CString(vDataInfo[i].chRecordTime));
			Data.fLoadPre = vDataInfo[i].fShangZhuangShangBa;
			Data.fLoadNext = vDataInfo[i].fWeiyiAvg;
			Data.fLoadoffPre = vDataInfo[i + 1].fShangZhuangShangBa;
			Data.fLoadoffNext = vDataInfo[i + 1].fWeiyiAvg;
			Data.fYouyaVal = vDataInfo[i].fCurYouya;
			if (bFirst)
			{
				Data.fSpLoad = Data.fLoadNext;
				Data.fSpLoadoff = Data.fLoadoffNext;
				bFirst = FALSE;
			}
			else
			{
				Data.fSpLoad = Data.fLoadNext - fLoadoffNext;			//当前 加载下表 - 上个数据的 卸载下表
				Data.fSpLoadoff = Data.fLoadoffNext - fLoadoffNext;	//当前 卸载下表 - 上个数据的 卸载下表
			}
			fLoadoffNext = Data.fLoadoffNext;
			Data.fPreNextGap = Data.fLoadPre - Data.fLoadNext;
			Data.fAngle = 0.0f;
			//反tan
			float f = 0.0f;
			if (Pro_Info.nTableGap != 0)
			{
				f = Data.fPreNextGap / Pro_Info.nTableGap;				
			}
			else
			{
				f = 0.0f;
			}
			Data.fAngle = float(atan(f) * 180 / PI);

			Data.nXunhuan++;
			if (Data.nXunhuan > Pro_Info.chXunHuanCnt)
			{
				Data.nXunhuan = 1;
			}
			vSpLoad.push_back(Data);
			i++;
		}		
	}
}

void CHZData::GetSpLoadValue(HZ_PROJECT_INFO Pro_Info, vector<DATA_INFO> vDataInfo, vector<TABLE_LOAD> &vTable_Load, vector<float> &vLoadValue)
{
	ClearVector(vTable_Load);
	//现获取时间序列
	float fLoadValue = 0; //本级值
	int nALlTime = 0;
	int nSize = (int)vDataInfo.size();
	TABLE_LOAD Data;
	BOOL bFirst = TRUE;
	for (int i = 0; i < nSize; ++i)
	{
		if (bFirst)
		{
			nALlTime = 0;
			fLoadValue = vDataInfo[i].fLoadValue;

			Data.nTime = nALlTime;
			Data.nJiaZai = vDataInfo[i].nJiaZaiOrXieZai;

			InsertTimeGap(vTable_Load, Data);
			bFirst = FALSE;
		}
		else
		{
			if (fLoadValue == vDataInfo[i].fLoadValue)
			{
				if (vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
				{
					nALlTime += Pro_Info.nLoadTime;
				}
				else
				{
					nALlTime += Pro_Info.nLoadoffTime;
				}
				Data.nTime = nALlTime;
				Data.nJiaZai = vDataInfo[i].nJiaZaiOrXieZai;

				InsertTimeGap(vTable_Load, Data);
			}
			else
			{
				nALlTime = 0;
				fLoadValue = vDataInfo[i].fLoadValue;
				Data.nTime = nALlTime;
				Data.nJiaZai = vDataInfo[i].nJiaZaiOrXieZai;

				InsertTimeGap(vTable_Load, Data);
			}
		}
	}
	//获取列数
	int nColCnt = 0;
	fLoadValue = 0;
	nColCnt = GetSpLoadTableColCnt(Pro_Info, m_vDataInfo, vLoadValue);
	//初始化
	BOOL bExist = FALSE;
	float fWeiyi = 0;
	for (int i = 0; i < (int)vTable_Load.size(); ++i)
	{
		for (int k = 0; k < (int)vLoadValue.size(); ++k)
		{
			vTable_Load[i].vExist.push_back(bExist);
			vTable_Load[i].vfWeiyi.push_back(fWeiyi);
			vTable_Load[i].vfUpWeiyi.push_back(fWeiyi);
		}
	}
	//获取数据
	int nCol = 0;
	bFirst = TRUE;
	for (int i = 0; i < nSize; ++i)
	{
		if (bFirst)
		{
			nALlTime = 0;
			fLoadValue = vDataInfo[i].fLoadValue;
			nCol = 0;
			InsertTimeData(vTable_Load, nALlTime, nCol, vDataInfo[i].fWeiyiAvg);
			bFirst = FALSE;
		}
		else
		{
			if (fLoadValue == vDataInfo[i].fLoadValue)
			{
				if (vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
				{
					nALlTime += Pro_Info.nLoadTime;
				}
				else
				{
					nALlTime += Pro_Info.nLoadoffTime;
				}
				InsertTimeData(vTable_Load, nALlTime, nCol, vDataInfo[i].fWeiyiAvg);
			}
			else
			{
				nALlTime = 0;
				fLoadValue = vDataInfo[i].fLoadValue;
				nCol++;
				InsertTimeData(vTable_Load, nALlTime, nCol, vDataInfo[i].fWeiyiAvg);
			}
		}
	}
}

//重置加卸载时间
void CHZData::ResetLoadTime()
{
	if (!g_bInitData || m_vLoadData.empty())
	{
		return;
	}
	int nTime = 0;
	for (int i = 1; i < (int)m_vLoadData.size(); ++i)
	{
		if (m_vLoadData[i].nJiaZai == LOADOFF_VALUE)
		{
			nTime += m_HZProInfo.nLoadTime;
		}
		else
		{
			nTime += m_HZProInfo.nLoadoffTime;
		}
		m_vLoadData[i].nTime = nTime;
	}
}

//重置循环次数
void CHZData::ResetXunHuan()
{
	if (!g_bInitData || m_vSpLoad.empty())
	{
		return;
	}
	int nCnt = 0;
	for (int i = 0; i < (int)m_vSpLoad.size(); ++i)
	{
		nCnt++;
		if (nCnt > m_HZProInfo.chXunHuanCnt)
		{
			nCnt = 1;
		}
		m_vSpLoad[i].nXunhuan = nCnt;
	}
}

//根据上下表距的变化重新计算角度
void CHZData::ReCalcAngle()
{
	if (!g_bInitData || m_vSpLoad.empty())
	{
		return;
	}
	float f = 0.0f;
	for (int i = 0; i < (int)m_vSpLoad.size(); ++i)
	{
		if (m_HZProInfo.nTableGap !=0 )
		{
			f = m_vSpLoad[i].fPreNextGap / m_HZProInfo.nTableGap;
		}
		else
		{
			f = 0.0f;
		}
		m_vSpLoad[i].fAngle = float(atan(f) * 180 / PI);
	}
}


void CHZData::GetLoadValue(HZ_PROJECT_INFO Pro_Info, vector<DATA_INFO>	vDataInfo, vector<TABLE_LOAD> &vTable_Load, vector<float> &vLoadValue, int nDataType)
{
	ClearVector(vTable_Load);
	//现获取时间序列
	float fLoadValue = 0; //本级值
	int nALlTime = 0;
	int nSize = (int)vDataInfo.size();
	TABLE_LOAD Data;
	BOOL bFirst = TRUE;
	int nCnt = 0;
	int nNo = 0; //序号
	for (int i = 0; i < nSize; ++i)
	{
		if (nDataType != vDataInfo[i].nJiaZaiOrXieZai)
		{
			continue;
		}
		if (bFirst)
		{
			nNo = vDataInfo[i].nIdx;
			nCnt = 0;
			if (nDataType == LOAD_VALUE)
			{
				nALlTime = Pro_Info.nLoadTimeList[nCnt];
			}
			else
			{
				nALlTime = Pro_Info.nLoadOffTimeList[nCnt];
			}
			fLoadValue = vDataInfo[i].fLoadValue;

			Data.nTime = nALlTime;
			InsertTimeGap(vTable_Load, Data);
			bFirst = FALSE;
		}
		else
		{
			if (fLoadValue == vDataInfo[i].fLoadValue && nNo == vDataInfo[i].nIdx)
			{
				nCnt++;
				nCnt = nCnt > 11 ? 11 : nCnt;
				if (nDataType == LOAD_VALUE)
				{
					nALlTime += Pro_Info.nLoadTimeList[nCnt];
				}
				else
				{
					nALlTime += Pro_Info.nLoadOffTimeList[nCnt];
				}
				Data.nTime = nALlTime;
				InsertTimeGap(vTable_Load, Data);
			}
			else
			{
				nCnt = 0;
				if (nDataType == LOAD_VALUE)
				{
					nALlTime = Pro_Info.nLoadTimeList[nCnt];
				}
				else
				{
					nALlTime = Pro_Info.nLoadOffTimeList[nCnt];
				}
				fLoadValue = vDataInfo[i].fLoadValue;
				nNo = vDataInfo[i].nIdx;
				Data.nTime = nALlTime;
				InsertTimeGap(vTable_Load, Data);
			}
		}
	}
	//获取N数
	int nColCnt = 0;
	fLoadValue = 0;
	nColCnt = GetLoadTableColCnt(Pro_Info, m_vDataInfo, vLoadValue, nDataType);
	//扩容
	BOOL bExist = FALSE;
	float fWeiyi = 0;
	for (int i = 0; i < (int)vTable_Load.size(); ++i)
	{
		for (int k = 0; k < (int)vLoadValue.size(); ++k)
		{
			vTable_Load[i].vExist.push_back(bExist);
			vTable_Load[i].vfWeiyi.push_back(fWeiyi);
			vTable_Load[i].vfUpWeiyi.push_back(fWeiyi);
		}
	}
	//获取数据
	int nCol = 0;
	bFirst = TRUE;
	for (int i = 0; i < nSize; ++i)
	{
		if (nDataType != vDataInfo[i].nJiaZaiOrXieZai)
		{
			continue;
		}
		if (bFirst)
		{
			nNo = vDataInfo[i].nIdx;
			nCnt = 0;
			if (nDataType == LOAD_VALUE)
			{
				nALlTime = Pro_Info.nLoadTimeList[nCnt];
			}
			else
			{
				nALlTime = Pro_Info.nLoadOffTimeList[nCnt];
			}
			fLoadValue = vDataInfo[i].fLoadValue;
			nCol = 0;
			InsertTimeData(vTable_Load, nALlTime, nCol, vDataInfo[i].fWeiyiAvg, vDataInfo[i].fShangZhuangShangBa);
			bFirst = FALSE;
		}
		else
		{
			if (fLoadValue == vDataInfo[i].fLoadValue && nNo == vDataInfo[i].nIdx)
			{
				nCnt++;
				nCnt = nCnt > 11 ? 11 : nCnt;
				if (nDataType == LOAD_VALUE)
				{
					nALlTime += Pro_Info.nLoadTimeList[nCnt];
				}
				else
				{
					nALlTime += Pro_Info.nLoadOffTimeList[nCnt];
				}
				InsertTimeData(vTable_Load, nALlTime, nCol, vDataInfo[i].fWeiyiAvg, vDataInfo[i].fShangZhuangShangBa);
			}
			else
			{
				nCnt = 0;
				nNo = vDataInfo[i].nIdx;
				if (nDataType == LOAD_VALUE)
				{
					nALlTime = Pro_Info.nLoadTimeList[nCnt];
				}
				else
				{
					nALlTime = Pro_Info.nLoadOffTimeList[nCnt];
				}
				fLoadValue = vDataInfo[i].fLoadValue;
				nCol++;
				InsertTimeData(vTable_Load, nALlTime, nCol, vDataInfo[i].fWeiyiAvg, vDataInfo[i].fShangZhuangShangBa);
			}
		}
	}
}



void CHZData::InsertTimeData(vector<TABLE_LOAD> &vTable_Load, int nTime, int nCol, float fVal, float fUpVal)
{
	for (int i = 0; i < (int)vTable_Load.size(); ++i)
	{
		if (vTable_Load[i].nTime == nTime)
		{
			if (nCol < (int)vTable_Load[i].vExist.size())
			{
				vTable_Load[i].vExist[nCol] = TRUE;
				vTable_Load[i].vfWeiyi[nCol] = fVal;
				vTable_Load[i].vfUpWeiyi[nCol] = fUpVal;
			}
			break;
		}
	}
}

void CHZData::InsertTimeGap(vector<TABLE_LOAD> &vTable_Load, TABLE_LOAD Data)
{
	if (vTable_Load.empty())
	{
		vTable_Load.push_back(Data);
	}
	else
	{
		int nSize = vTable_Load.size();
		int i = 0;
		for (i = 0; i < nSize; ++i)
		{
			if (Data.nTime == vTable_Load[i].nTime)
			{
				break;
			}
			else if (Data.nTime < vTable_Load[i].nTime)
			{
				vTable_Load.insert(vTable_Load.begin() + i, Data);
				break;
			}
		}
		if (i == nSize)
		{
			vTable_Load.push_back(Data);
		}
	}
}


void CHZData::ModifyTiemGap()
{
	if (g_DataType == DATA_1)
	{
		ModifyTiemGapDataType1();
	}
	if (g_DataType == DATA_2)
	{
		ModifyTiemGapDataType2();
	}
	else
	{
		ModifyTiemGapDataType0();
	}
}

void CHZData::ModifyTiemGapDataType2()
{
	CString strTime(L"");
	USES_CONVERSION;
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
		{
			if (m_vDataInfo[i].nRecordId < 12)
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadTimeList[m_vDataInfo[i].nRecordId];
			}
			else
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadTimeList[m_vDataInfo[i].nRecordId];
			}
		}
		else
		{
			if (m_vDataInfo[i].nRecordId < 12)
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadOffTimeList[m_vDataInfo[i].nRecordId];
			}
			else
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadOffTimeList[m_vDataInfo[i].nRecordId];
			}
		}
		//修改时间间隔会连带时间修改
		if (i > 1)
		{
			strTime = GetTimeAdd(m_vDataInfo[i - 1].chRecordTime, m_vDataInfo[i].nTimeGap * 60);
			strcpy_s(m_vDataInfo[i].chRecordTime, sizeof(m_vDataInfo[i].chRecordTime), W2A(strTime));
		}
	}
	InitCalcData();
}

void CHZData::ModifyTiemGapDataType1()
{
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
		{
			if (m_vDataInfo[i].nRecordId < 12)
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadTimeList[m_vDataInfo[i].nRecordId];
			}
			else
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadTimeList[m_vDataInfo[i].nRecordId];
			}
		}
		else
		{
			if (m_vDataInfo[i].nRecordId < 12)
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadOffTimeList[m_vDataInfo[i].nRecordId];
			}
			else
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadOffTimeList[m_vDataInfo[i].nRecordId];
			}
		}
	}
	InitCalcData();
}
//修改时间间隔
void CHZData::ModifyTiemGapDataType0()
{
	int nALlTime = 0;
	int nCnt = 0;
	for (int i = 0; i < (int)m_vLoadData.size(); ++i)
	{
		nALlTime += m_HZProInfo.nLoadTimeList[nCnt];
		m_vLoadData[i].nTime = nALlTime;
		nCnt++;
		if (nCnt > 11)
		{
			nCnt = 11;
		}
	}

	nCnt = 0;
	nALlTime = 0;
	for (int i = 0; i < (int)m_vLoadOffData.size(); ++i)
	{
		nALlTime += m_HZProInfo.nLoadOffTimeList[nCnt];
		m_vLoadOffData[i].nTime = nALlTime;
		nCnt++;
		if (nCnt > 11)
		{
			nCnt = 11;
		}
	}

	int nTimeGap = 0;
	nALlTime = 0;
	for (int i = 0; i < (int)m_vSummaryData.size(); ++i)
	{
		nCnt = 0;
		nTimeGap = 0;
		for (int t = 0; t < m_vSummaryData[i].nDataCnt; ++t)
		{
			if (m_vSummaryData[i].nJiaZaiOrXieZai == 3)
			{
				nTimeGap += m_HZProInfo.nLoadTimeList[nCnt];
			}
			else
			{
				nTimeGap += m_HZProInfo.nLoadOffTimeList[nCnt];
			}
			nCnt++;
			if (nCnt > 11)
			{
				nCnt = 11;
			}
		}
		nALlTime += nTimeGap;
		m_vSummaryData[i].nTimeGap = nTimeGap;
		m_vSummaryData[i].nALlTime = nALlTime;
	}

	CString strTime(L"");
	USES_CONVERSION;
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (m_vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
		{
			if (m_vDataInfo[i].nRecordId < 12)
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadTimeList[m_vDataInfo[i].nRecordId];
			}
			else
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadTimeList[m_vDataInfo[i].nRecordId];
			}
		}
		else
		{
			if (m_vDataInfo[i].nRecordId < 12)
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadOffTimeList[m_vDataInfo[i].nRecordId];
			}
			else
			{
				m_vDataInfo[i].nTimeGap = m_HZProInfo.nLoadOffTimeList[m_vDataInfo[i].nRecordId];
			}
		}
		//修改时间间隔会连带时间修改
		if (i > 1)
		{
			strTime = GetTimeAdd(m_vDataInfo[i - 1].chRecordTime, m_vDataInfo[i].nTimeGap * 60);
			strcpy_s(m_vDataInfo[i].chRecordTime, sizeof(m_vDataInfo[i].chRecordTime), W2A(strTime));
		}
	}
}

//原始记录表时间
void CHZData::ModifyOriginalTimeGap()
{
	vector<DATA_INFO> DataInfo = GetDataInfo();
	HZ_PROJECT_INFO ProInfo = GetProjectInfo();

	for (int i = 0; i < (int)DataInfo.size(); ++i)
	{
		if (DataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
		{
			if (DataInfo[i].nRecordId < 12)
			{
				DataInfo[i].nTimeGap = ProInfo.nLoadTimeList[m_vDataInfo[i].nRecordId];
			}
			else
			{
				DataInfo[i].nTimeGap = ProInfo.nLoadTimeList[m_vDataInfo[i].nRecordId];
			}
		}
		else
		{
			if (DataInfo[i].nRecordId < 12)
			{
				DataInfo[i].nTimeGap = ProInfo.nLoadOffTimeList[m_vDataInfo[i].nRecordId];
			}
			else
			{
				DataInfo[i].nTimeGap = ProInfo.nLoadOffTimeList[m_vDataInfo[i].nRecordId];
			}
		}
	}
	SetDataInfo(DataInfo);
	InitCalcData();
}

//修改水平多循环荷载本级值
void CHZData::ModifySpLoad(int nNo, float fLoadVal)
{
	if (nNo < 0)
	{
		return;
	}
	float fVal = m_vLoadValue[nNo];
	int nCnt = 0;
	float nLastVal = 0;
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (i == 0)
		{
			nLastVal = m_vDataInfo[i].fLoadValue;
		}
		else
		{
			if (nLastVal != m_vDataInfo[i].fLoadValue)
			{
				nCnt++;
				nLastVal = m_vDataInfo[i].fLoadValue;
			}
		}
		if (nCnt == nNo && m_vDataInfo[i].fLoadValue == fVal)
		{
			m_vDataInfo[i].fLoadValue = fLoadVal;
		}
	}
	InitCalcData();
}

//修改荷载本级值
void CHZData::ModifyLoad(int nNo, float fLoadVal, int nDataType)
{
	if (nNo < 0)
	{
		return;
	}
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (m_vDataInfo[i].nIdx == nNo && nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
		{
			m_vDataInfo[i].fLoadValue = fLoadVal;
		}
	}

	if (nDataType == LOAD_VALUE)
	{
		if (nNo < (int)m_vLoadValue.size())
		{
			m_vLoadValue[nNo] = fLoadVal;
			m_vSummaryData[nNo].fLoadVal = fLoadVal;
		}
	}
	else
	{
		if (nNo < (int)m_vLoadoffValue.size())
		{
			m_vLoadoffValue[nNo] = fLoadVal;
			m_vSummaryData[nNo + (int)m_vLoadValue.size()].fLoadVal = fLoadVal;
		}
	}
}


//修改时间间隔
void CHZData::ModifyTimeValue(int nNo, int &nTime, int nDataType)
{
	if (nNo == 0 || nNo > 11)
	{
		return;
	}

	int nLastGap = 0;
	int nNestGap = 0;
	if (nDataType == LOAD_VALUE)
	{
		if (nNo == 11)
		{
			nTime = nTime > SIMPLE_VALUE ? SIMPLE_VALUE : nTime;
			m_HZProInfo.nLoadTimeList[nNo] = nTime;
		}
		else
		{
			if (nTime < m_vLoadData[nNo - 1].nTime)
			{
				nTime = m_vLoadData[nNo - 1].nTime;
			}
			else if (nNo < (int)m_vLoadData.size() - 1 && nTime > m_vLoadData[nNo + 1].nTime)
			{
				nTime = m_vLoadData[nNo + 1].nTime;
			}

			nLastGap = nTime - m_vLoadData[nNo - 1].nTime;
			if (nNo < (int)m_vLoadData.size() - 1)
			{
				nNestGap = m_vLoadData[nNo + 1].nTime - nTime;
			}
			else
			{
				nNestGap = m_HZProInfo.nLoadTimeList[nNo + 1];
			}
			m_HZProInfo.nLoadTimeList[nNo] = nLastGap;
			m_HZProInfo.nLoadTimeList[nNo + 1] = nNestGap;
		}
	}
	else
	{
		if (nNo == 11)
		{
			nTime = nTime > SIMPLE_VALUE ? SIMPLE_VALUE : nTime;
			m_HZProInfo.nLoadOffTimeList[nNo] = nTime;
		}
		else
		{
			if (nTime < m_vLoadOffData[nNo - 1].nTime)
			{
				nTime = m_vLoadOffData[nNo - 1].nTime;
			}
			else if (nNo < (int)m_vLoadOffData.size() - 1 && nTime > m_vLoadOffData[nNo + 1].nTime)
			{
				nTime = m_vLoadOffData[nNo + 1].nTime;
			}

			nLastGap = nTime - m_vLoadOffData[nNo - 1].nTime;
			if (nNo < (int)m_vLoadOffData.size() - 1)
			{
				nNestGap = m_vLoadOffData[nNo + 1].nTime - nTime;
			}
			else
			{
				nNestGap = m_HZProInfo.nLoadOffTimeList[nNo + 1];
			}
			m_HZProInfo.nLoadOffTimeList[nNo] = nLastGap;
			m_HZProInfo.nLoadOffTimeList[nNo + 1] = nNestGap;
		}
	}
	ModifyTiemGap();
}

//当前千牛的数据个数
vector<int> CHZData::GetSpDataRows(vector<DATA_INFO> vDataInfo)
{
	int nCnt = 0;
	vector<int> vCnt;
	float fVal = 0;

	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (i == 0)
		{
			fVal = m_vDataInfo[i].fLoadValue;
			nCnt = 1;
		}
		else
		{
			if (fVal != m_vDataInfo[i].fLoadValue)
			{
				vCnt.push_back(nCnt);

				fVal = m_vDataInfo[i].fLoadValue;
				nCnt = 1;
			}
			else
			{
				nCnt++;
			}
		}
	}
	vCnt.push_back(nCnt);
	return vCnt;
}

//获取当数据所在行
int CHZData::GetSpDataRow(int nRow, int nCol)
{
	int nCnt = 0;
	for (int i = 0; i < (int)m_vLoadValue.size() && i < nCol; i++)
	{
		for (int n = 0; n < (int)m_vLoadData.size(); ++n)
		{
			if (m_vLoadData[n].vExist[i])
			{
				nCnt++;
			}
		}
	}
	nCnt += nRow;
	return nCnt;
}

//修改水平多循环位移平均值
void CHZData::ModifySpWeiYiAvgVal(int nRow, int nCol, float fVal)
{
	m_vLoadData[nRow].vfWeiyi[nCol] += fVal;

	int nCnt = GetSpDataRow(nRow, nCol);
	m_vDataInfo[nCnt].fWeiyiAvg += fVal;
	CheckValue(m_vDataInfo[nCnt].fWeiyiAvg);
	for (int i = 0; i < 8; ++i)
	{
		if (m_HZProInfo.chChanelUsed[i] != 0 && m_HZProInfo.chChannelSel[i] == 1)
		{
			m_vDataInfo[nCnt].fWeiyi[i] += fVal;
			CheckValue(m_vDataInfo[nCnt].fWeiyi[i]);
		}
	}
	GetSpJiluData(m_HZProInfo, m_vDataInfo, m_vSpLoad);
}

//修改位移平均值
void CHZData::ModiyfWeiYiAvgVal(int nRow, int nCol, float fVal, int nDataType)
{
	int nNo = nCol;
	if (nDataType == LOAD_VALUE)
	{
		m_vLoadData[nRow].vfWeiyi[nCol] += fVal;
	}
	else
	{
		m_vLoadOffData[nRow].vfWeiyi[nCol] += fVal;
		nNo += (int)m_vLoadValue.size();
	}
	//获取当前坐标在数据中的位置
	int nCnt = 0;
	for (int n = 0; n < nNo; ++n)
	{
		nCnt += m_vSummaryData[n].nDataCnt;
	}
	nCnt += nRow;
	m_vDataInfo[nCnt].fWeiyiAvg += fVal;
	CheckValue(m_vDataInfo[nCnt].fWeiyiAvg);
	for (int i = 0; i < 8; ++i)
	{
		if (m_HZProInfo.chChanelUsed[i] != 0 && m_HZProInfo.chChannelSel[i] == 1)
		{
			m_vDataInfo[nCnt].fWeiyi[i] += fVal;
			CheckValue(m_vDataInfo[nCnt].fWeiyi[i]);
		}
	}

	CalcSummaryDataNew(m_vSummaryData);
}

//修改位移平均值
void CHZData::ModiyfZphWeiYiAvgVal(int nRow, int nCol, float fVal, int nDataType)
{
	int nNo = nCol / 2;
	if (nDataType == LOAD_VALUE)
	{
		if (nCol % 2 == 0)
		{
			m_vLoadData[nRow].vfWeiyi[nCol / 2] += fVal;
		}
		else
		{
			m_vLoadData[nRow].vfUpWeiyi[nCol / 2] += fVal;
		}	
	}
	else
	{
		if (nCol % 2 == 0)
		{
			m_vLoadOffData[nRow].vfWeiyi[nCol / 2] += fVal;
		}
		else
		{
			m_vLoadOffData[nRow].vfUpWeiyi[nCol / 2] += fVal;
		}

		nNo += (int)m_vLoadValue.size();
	}
	//获取当前坐标在数据中的位置
	int nCnt = 0;
	for (int n = 0; n < nNo; ++n)
	{
		nCnt += m_vSummaryData[n].nDataCnt;
	}
	nCnt += nRow;
	if (nCol % 2 == 0)
	{
		m_vDataInfo[nCnt].fWeiyiAvg += fVal;
		CheckValue(m_vDataInfo[nCnt].fWeiyiAvg);

		for (int i = 0; i < 8; ++i)
		{
			if (m_HZProInfo.chChanelUsed[i] != 0 && m_HZProInfo.chChannelSel[i] == 1)
			{
				m_vDataInfo[nCnt].fWeiyi[i] += fVal;
				CheckValue(m_vDataInfo[nCnt].fWeiyi[i]);
			}
		}
	}
	else
	{
		m_vDataInfo[nCnt].fShangZhuangShangBa += fVal;
		CheckValue(m_vDataInfo[nCnt].fShangZhuangShangBa);
	}

	CalcSummaryDataNew(m_vSummaryData);
}

//水平多循环原始记录插入一记录
void CHZData::InsertSpOriTimeData1(vector<DATA_INFO> &vData, int nNo, int nBenjiId, BOOL bAdd)
{
	if (bAdd)
	{
		DATA_INFO info = vData[nNo];
		if (info.nJiaZaiOrXieZai == LOAD_VALUE)
		{
			info.nJiaZaiOrXieZai = LOADOFF_VALUE;
		}
		else
		{
			info.nJiaZaiOrXieZai = LOAD_VALUE;
		}
		vData.insert(vData.begin() + nNo + 1, info);
	}
	else
	{
		vData.erase(vData.begin() + nNo);
	}
}

//水平多循环插入一记录
void CHZData::InsertSpTimeData1(vector<DATA_INFO> &vData, int nNo, int nBenjiId, BOOL bAdd)
{
	//bAdd  TRUE 是增加   FALSE 是删减
	//nBenjiId == -1  是插入一行  == 1000 是删除当前行

	if (nBenjiId == -1 || nBenjiId == 1000)
	{
		vector<DATA_INFO> vDataInfo;
		DATA_INFO DataInfo;
		float fVal = 0.0f;
		int nCnt = 0;
		for (int i = 0; i < (int)vData.size(); ++i)
		{
			DataInfo = vData[i];

			if (i == 0)
			{
				fVal = DataInfo.fLoadValue;
				nCnt = 0;
			}
			else
			{
				if (fVal != DataInfo.fLoadValue)
				{
					nCnt = 0;
					fVal = DataInfo.fLoadValue;
				}
				else
				{
					nCnt++;
				}
			}

			if (nCnt == nNo)
			{
				if (nBenjiId == -1)
				{
					vDataInfo.push_back(DataInfo);
					if (nNo == 0)
					{
						DataInfo.nJiaZaiOrXieZai = LOAD_VALUE;
					}
					else
					{
						if (DataInfo.nJiaZaiOrXieZai == LOAD_VALUE)
						{
							DataInfo.nJiaZaiOrXieZai = LOADOFF_VALUE;
						}
						else
						{
							DataInfo.nJiaZaiOrXieZai = LOAD_VALUE;
						}
					}
					
					vDataInfo.push_back(DataInfo);
				}
			}
			else
			{
				vDataInfo.push_back(DataInfo);
			}
		}
		vData = vDataInfo;
		vDataInfo.clear();
	}
	else
	{
		//先获取本机KN 的数据个数
		vector<int> vNums = GetSpDataRows(vData);

		//本级的开始位置 和结束位置
		DATA_INFO DataInfo;
		ZeroMemory(&DataInfo, sizeof(DataInfo));
		int nBeginNo = 0, nEndNo = 0;

		for (int i = 0; i < (int)vNums.size(); ++i)
		{
			if (i == 0)
			{
				nBeginNo = 0;
				nEndNo = vNums[0];
			}
			else
			{
				nBeginNo += vNums[i - 1];
				nEndNo += vNums[i];
			}

			if (nBenjiId == i)
			{
				if (bAdd)
				{
					DataInfo = vData[nBeginNo + nNo];
					//如果当前行 小于所以数据行  则判断插入的加卸载 是否符合当前行的 加卸载
// 					if (nNo < (int)m_vLoadData.size() - 1)
// 					{
// 						DataInfo.nJiaZaiOrXieZai = m_vLoadData[nNo + 1].nJiaZai;
// 					}
// 					else
					{
						if (DataInfo.nJiaZaiOrXieZai == LOAD_VALUE)
						{
							DataInfo.nJiaZaiOrXieZai = LOADOFF_VALUE;
						}
						else
						{
							DataInfo.nJiaZaiOrXieZai = LOAD_VALUE;
						}
					}
					vData.insert(vData.begin() + nBeginNo + nNo + 1, DataInfo);

					//判断下个数是否满足加卸载
					if (nBeginNo + nNo < nEndNo - 1 && nNo + 1 < (int)m_vLoadData.size() && DataInfo.nJiaZaiOrXieZai == m_vLoadData[nNo + 1].nJiaZai)
					{
						if (DataInfo.nJiaZaiOrXieZai == LOAD_VALUE)
						{
							DataInfo.nJiaZaiOrXieZai = LOADOFF_VALUE;
						}
						else
						{
							DataInfo.nJiaZaiOrXieZai = LOAD_VALUE;
						}
						vData.insert(vData.begin() + nBeginNo + nNo + 2, DataInfo);
					}


// 					if (nBeginNo + nNo < nEndNo - 1 && nNo + 2 < (int)m_vLoadData.size())
// 					{
// 						if (vData[nBeginNo + nNo + 2].nJiaZaiOrXieZai != m_vLoadData[nNo + 2].nJiaZai)
// 						{
// 							DataInfo.nJiaZaiOrXieZai = m_vLoadData[nNo + 2].nJiaZai;
// 							vData.insert(vData.begin() + nBeginNo + nNo + 2, DataInfo);
// 						}
// 					}
				}
				else
				{
					vData.erase(vData.begin() + nBeginNo + nNo);
					if (nBeginNo + nNo < nEndNo - 1 && vData[nBeginNo + nNo].nJiaZaiOrXieZai != m_vLoadData[nNo].nJiaZai)
					{
						vData.erase(vData.begin() + nBeginNo + nNo);
					}
				}
				break;
			}
		}
	}

}

void CHZData::InsertTimeData1(vector<DATA_INFO> &vData, int nNo, int nBenjiId, int nDataType, BOOL bAdd)
{
	//nBenjiId == 1000 表明是删除此行 
	vector<DATA_INFO> vDataInfo;
	int nId = 0;//本级ID
	int nBenJiId = 0;
	BOOL bInsert = FALSE;
	for (int i = 0; i < (int)vData.size(); ++i)
	{
		if (bInsert && nId == vData[i].nIdx)
		{
			if (!bAdd)
			{
				vData[i].nRecordId--;
			}
			else
			{
				vData[i].nRecordId++;
			}
		}
		else
		{
			bInsert = FALSE;
		}

		if (nBenjiId < 0)
		{	//一行数据
			if (nNo == vData[i].nRecordId && nDataType == vData[i].nJiaZaiOrXieZai)
			{
				bInsert = TRUE;
				vDataInfo.push_back(vData[i]);
				vData[i].nRecordId++;
				vDataInfo.push_back(vData[i]);
			}
			else
			{
				vDataInfo.push_back(vData[i]);
			}
			nId = vData[i].nIdx;
		}
		else
		{
			//一个数据
			if (!bInsert && nNo == vData[i].nRecordId
				&& nBenjiId == vData[i].nIdx
				&& nDataType == vData[i].nJiaZaiOrXieZai)
			{
				bInsert = TRUE;
				if (bAdd)
				{
					vDataInfo.push_back(vData[i]);
					vData[i].nRecordId++;
					vDataInfo.push_back(vData[i]);
				}
			}
			else
			{
				if (!bInsert && nBenjiId == 1000 && nNo == vData[i].nRecordId && nDataType == vData[i].nJiaZaiOrXieZai)
				{
					bInsert = TRUE;
				}
				else
				{
					vDataInfo.push_back(vData[i]);
				}
			}
			if (!vDataInfo.empty())
			{
				nBenJiId = vDataInfo[vDataInfo.size() - 1].nIdx;
			}
			nId = vData[i].nIdx;
		}
	}

	vData = vDataInfo;
	ClearVector(vDataInfo);
}

void CHZData::InsertZphTimeData1(vector<DATA_INFO> &vData, int nNo, int nBenjiId, int nDataType, BOOL bAdd)
{
	//nBenjiId == 1000 表明是删除此行 
	vector<DATA_INFO> vDataInfo;
	int nId = 0;//本级ID
//	int nBenJiId = 0;
	if (nBenjiId != 1000 && nBenjiId != -1)
	{
		nBenjiId = nBenjiId / 2;
	}
	
	BOOL bInsert = FALSE;
	for (int i = 0; i < (int)vData.size(); ++i)
	{
		if (bInsert && nId == vData[i].nIdx)
		{
			if (!bAdd)
			{
				vData[i].nRecordId--;
			}
			else
			{
				vData[i].nRecordId++;
			}
		}
		else
		{
			bInsert = FALSE;
		}

		if (nBenjiId < 0)
		{	//一行数据
			if (nNo == vData[i].nRecordId && nDataType == vData[i].nJiaZaiOrXieZai)
			{
				bInsert = TRUE;
				vDataInfo.push_back(vData[i]);
				vData[i].nRecordId++;
				vDataInfo.push_back(vData[i]);
			}
			else
			{
				vDataInfo.push_back(vData[i]);
			}
			nId = vData[i].nIdx;
		}
		else
		{
			//一个数据
			if (!bInsert && nNo == vData[i].nRecordId
				&& nBenjiId == vData[i].nIdx
				&& nDataType == vData[i].nJiaZaiOrXieZai)
			{
				bInsert = TRUE;
				if (bAdd)
				{
					vDataInfo.push_back(vData[i]);
					vData[i].nRecordId++;
					vDataInfo.push_back(vData[i]);
				}
			}
			else
			{
				if (!bInsert && nBenjiId == 1000 && nNo == vData[i].nRecordId && nDataType == vData[i].nJiaZaiOrXieZai)
				{
					bInsert = TRUE;
				}
				else
				{
					vDataInfo.push_back(vData[i]);
				}
			}
// 			if (!vDataInfo.empty())
// 			{
// 				nBenJiId = vDataInfo[vDataInfo.size() - 1].nIdx;
// 			}
			nId = vData[i].nIdx;
		}
	}

	vData = vDataInfo;
	ClearVector(vDataInfo);
}

void CHZData::InsertMgTimeData1(vector<DATA_INFO> &vData, int nNo, BOOL bAdd)
{
	int nBeginNo = 0, nEndNo = 0;
	GetMgDataNo(vData, nNo, nBeginNo, nEndNo);
	if (bAdd)
	{
		vData.insert(vData.begin() + nNo, vData[nNo]);
		for (int i = nNo + 1; i <= nEndNo + 1; ++i)
		{
			vData[i].nRecordId++;
		}
	}
	else
	{
		vData.erase(vData.begin() + nNo);
		if (nNo < (int)vData.size() - 1)
		{
			for (int i = nNo; i <= nEndNo - 1; ++i)
			{
				vData[i].nRecordId--;
			}
		}		
	}
}

//插入一行数据
void CHZData::InsertTimeData(int nNo, int nBenjiId, int nDataType, BOOL bAdd, BOOL bOriginal)
{
	vector<DATA_INFO> DataInfo = GetDataInfo();
	HZ_PROJECT_INFO ProInfo = GetProjectInfo();
	if (g_DataType == DATA_0)
	{
		if (bOriginal)
		{
			InsertTimeData1(DataInfo, nNo, nBenjiId, nDataType, bAdd);
			ProInfo.nDataCnt = (int)DataInfo.size();
			SetDataInfo(DataInfo);
			SetProjectInfo(ProInfo);
		}
		else{
			InsertTimeData1(m_vDataInfo, nNo, nBenjiId, nDataType, bAdd);
			m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
		}
	}
	else if (g_DataType == DATA_1)
	{
		if (bOriginal)
		{
			InsertMgTimeData1(DataInfo, nNo, bAdd);
			ProInfo.nDataCnt = (int)DataInfo.size();
			SetDataInfo(DataInfo);
			SetProjectInfo(ProInfo);
		}
		else
		{
			InsertMgTimeData1(m_vDataInfo, nNo, bAdd);
			m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
		}
	}
	else if (g_DataType == DATA_2) //水平多循环试验
	{
		if (bOriginal)
		{
			InsertSpOriTimeData1(DataInfo, nNo, nBenjiId, bAdd);
			ProInfo.nDataCnt = (int)DataInfo.size();
			SetDataInfo(DataInfo);
			SetProjectInfo(ProInfo);
		}
		else
		{
			InsertSpTimeData1(m_vDataInfo, nNo, nBenjiId, bAdd);
			m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
		}
	}
	else if (g_DataType == DATA_3)	//自平衡试验
	{
		if (bOriginal)
		{
			InsertTimeData1(DataInfo, nNo, nBenjiId, nDataType, bAdd);
			ProInfo.nDataCnt = (int)DataInfo.size();
			SetDataInfo(DataInfo);
			SetProjectInfo(ProInfo);
		}
		else
		{
			InsertZphTimeData1(m_vDataInfo, nNo, nBenjiId, nDataType, bAdd);
			m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
		}
	}
	InitCalcData();
}


// void CHZData::InsertTimeData(int nNo, int nBenjiId, int nDataType, BOOL bAdd, BOOL bOriginal)
// {
// 	//nBenjiId == 1000 表明是删除此行 
// 	vector<DATA_INFO> vDataInfo;
// 	int nId = 0;//本级ID
// 	int nBenJiId = 0;
// 	BOOL bInsert = FALSE;
// 	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
// 	{
// 		if (bInsert && nId == m_vDataInfo[i].nIdx)
// 		{
// 			if (!bAdd)
// 			{
// 				m_vDataInfo[i].nRecordId--;
// 			}
// 			else
// 			{
// 				m_vDataInfo[i].nRecordId++;
// 			}	
// 		}
// 		else
// 		{
// 			bInsert = FALSE;
// 		}
// 
// 		if (nBenjiId < 0)
// 		{	//一行数据
// 			if (nNo == m_vDataInfo[i].nRecordId && nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 			{
// 				bInsert = TRUE;
// 				vDataInfo.push_back(m_vDataInfo[i]);
// 				m_vDataInfo[i].nRecordId++;
// 				vDataInfo.push_back(m_vDataInfo[i]);
// 			}
// 			else
// 			{
// 				vDataInfo.push_back(m_vDataInfo[i]);
// 			}
// 			nId = m_vDataInfo[i].nIdx;
// 		}
// 		else
// 		{
// 			//一个数据
// 			if (!bInsert && nNo == m_vDataInfo[i].nRecordId
// 				&& nBenjiId == m_vDataInfo[i].nIdx
// 				&& nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 			{
// 				bInsert = TRUE;
// 				if (bAdd)
// 				{	
// 					vDataInfo.push_back(m_vDataInfo[i]);
// 					m_vDataInfo[i].nRecordId++;
// 					vDataInfo.push_back(m_vDataInfo[i]);
// 				}
// 			}
// 			else
// 			{
// 				if (!bInsert && nBenjiId == 1000 && nNo == m_vDataInfo[i].nRecordId && nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 				{
// 					bInsert = TRUE;
// 				}
// 				else
// 				{
// 					vDataInfo.push_back(m_vDataInfo[i]);
// 				}
// 			}
// 			if (!vDataInfo.empty())
// 			{
// 				nBenJiId = vDataInfo[vDataInfo.size() - 1].nIdx;
// 			}
// 			nId = m_vDataInfo[i].nIdx;
// 		}
// 	}
// 	//反赋值
// 	m_HZProInfo.nDataCnt = (int)vDataInfo.size();
// 	m_vDataInfo = vDataInfo;
// 	InitCalcData();
// }


void CHZData::InsertGrade1(vector<DATA_INFO> &vData, int nNo, int nDataType, BOOL bAdd)
{
	vector<DATA_INFO> vAddInfo;
	vector<DATA_INFO> vDataInfo;
	int nId = 0;//本级ID
	BOOL bOpere = FALSE;
	BOOL bOver = FALSE;
	for (int i = 0; i < (int)vData.size(); ++i)
	{
		if (bAdd)
		{
			if (vData[i].nIdx == nNo && nDataType == vData[i].nJiaZaiOrXieZai)
			{
				bOpere = TRUE;
				vDataInfo.push_back(vData[i]);
				vAddInfo.push_back(vData[i]);
			}
			else
			{
				//遇到插入值，且不为空 则本级id++插入  
				if (bOpere && !vAddInfo.empty())
				{
					for (int n = 0; n < (int)vAddInfo.size(); ++n)
					{
						if (nDataType == vAddInfo[n].nJiaZaiOrXieZai)
						{
							vAddInfo[n].nIdx++;
						}

						vDataInfo.push_back(vAddInfo[n]);
					}
					vAddInfo.clear();
					if (nDataType == vData[i].nJiaZaiOrXieZai)
					{
						vData[i].nIdx++;
					}

					vDataInfo.push_back(vData[i]);
				}
				else if (bOpere) //遇到插入值，后续的本级id都++
				{
					if (nDataType == vData[i].nJiaZaiOrXieZai)
					{
						vData[i].nIdx++;
					}
					vDataInfo.push_back(vData[i]);
				}
				else
				{
					vDataInfo.push_back(vData[i]);
				}
			}
		}
		else
		{
			if (!bOver && vData[i].nIdx == nNo && nDataType == vData[i].nJiaZaiOrXieZai)
			{
				bOpere = TRUE;
				continue;
			}
			else
			{
				//bOpere == TRUE 表明已经遇到删除对象 则本级ID--
				if (bOpere)
				{
					if (nDataType == vData[i].nJiaZaiOrXieZai)
					{
						vData[i].nIdx--;
					}
					bOver = TRUE;
				}
				vDataInfo.push_back(vData[i]);
			}
		}
	}
	if (!vAddInfo.empty())
	{
		for (int n = 0; n < (int)vAddInfo.size(); ++n)
		{
			if (nDataType == vAddInfo[n].nJiaZaiOrXieZai)
			{
				vAddInfo[n].nIdx++;
			}
			vDataInfo.push_back(vAddInfo[n]);
		}
	}
	vData = vDataInfo;
	ClearVector(vDataInfo);
	ClearVector(vAddInfo);
}

void CHZData::InsertZphGrade1(vector<DATA_INFO> &vData, int nNo, int nDataType, BOOL bAdd)
{
	vector<DATA_INFO> vAddInfo;
	vector<DATA_INFO> vDataInfo;
	int nId = 0;//本级ID
	BOOL bOpere = FALSE;
	BOOL bOver = FALSE;
//	nNo = nNo / 2;
	for (int i = 0; i < (int)vData.size(); ++i)
	{
		if (bAdd)
		{
			if (vData[i].nIdx == nNo && nDataType == vData[i].nJiaZaiOrXieZai)
			{
				bOpere = TRUE;
				vDataInfo.push_back(vData[i]);
				vAddInfo.push_back(vData[i]);
			}
			else
			{
				//遇到插入值，且不为空 则本级id++插入  
				if (bOpere && !vAddInfo.empty())
				{
					for (int n = 0; n < (int)vAddInfo.size(); ++n)
					{
						if (nDataType == vAddInfo[n].nJiaZaiOrXieZai)
						{
							vAddInfo[n].nIdx++;
						}

						vDataInfo.push_back(vAddInfo[n]);
					}
					vAddInfo.clear();
					if (nDataType == vData[i].nJiaZaiOrXieZai)
					{
						vData[i].nIdx++;
					}

					vDataInfo.push_back(vData[i]);
				}
				else if (bOpere) //遇到插入值，后续的本级id都++
				{
					if (nDataType == vData[i].nJiaZaiOrXieZai)
					{
						vData[i].nIdx++;
					}
					vDataInfo.push_back(vData[i]);
				}
				else
				{
					vDataInfo.push_back(vData[i]);
				}
			}
		}
		else
		{
			if (!bOver && vData[i].nIdx == nNo && nDataType == vData[i].nJiaZaiOrXieZai)
			{
				bOpere = TRUE;
				continue;
			}
			else
			{
				//bOpere == TRUE 表明已经遇到删除对象 则本级ID--
				if (bOpere)
				{
					if (nDataType == vData[i].nJiaZaiOrXieZai)
					{
						vData[i].nIdx--;
					}
					bOver = TRUE;
				}
				vDataInfo.push_back(vData[i]);
			}
		}
	}
	if (!vAddInfo.empty())
	{
		for (int n = 0; n < (int)vAddInfo.size(); ++n)
		{
			if (nDataType == vAddInfo[n].nJiaZaiOrXieZai)
			{
				vAddInfo[n].nIdx++;
			}
			vDataInfo.push_back(vAddInfo[n]);
		}
	}
	vData = vDataInfo;
	ClearVector(vDataInfo);
	ClearVector(vAddInfo);
}

//原始数据集插入一级
void CHZData::InsertSpOriGrade1(vector<DATA_INFO> &vData, int nNo, BOOL bAdd)
{
	DATA_INFO info = vData[nNo];
	if (bAdd)
	{
		int nLastNo = vData.size();
		for (int i = nNo; i < (int)vData.size(); ++i)
		{
			if (vData[i].fLoadValue != info.fLoadValue)
			{
				nLastNo = i;
				break;
			}
		}

		info = vData[nLastNo - 1];
		if (nLastNo < (int)vData.size())
		{
			info.fLoadValue = (vData[nLastNo].fLoadValue + info.fLoadValue) / 2;
		}
		else
		{
			info.fLoadValue += 50;
		}
		info.nJiaZaiOrXieZai = LOAD_VALUE;
		vData.insert(vData.begin() + nLastNo, info);
	}
	else
	{
		vector<DATA_INFO> vDataDest;
		for (int i = 0; i < (int)vData.size(); ++i)
		{
			if (vData[i].fLoadValue == info.fLoadValue)
			{
				continue;
			}
			vDataDest.push_back(vData[i]);
		}
		vData = vDataDest;
	}
}

//插入一级
void CHZData::InsertSpGrade1(vector<DATA_INFO> &vData, int nNo, BOOL bAdd)
{
	//先获取本机KN 的数据个数
	vector<int> vNums = GetSpDataRows(m_vDataInfo);
	if (bAdd)
	{
		DATA_INFO DataInfo;

		if (nNo == vNums.size() - 1)
		{
			DataInfo = vData[vData.size() - 1];
			DataInfo.nJiaZaiOrXieZai = LOAD_VALUE;
			DataInfo.fLoadValue += 20;
			vData.push_back(DataInfo);
		}
		else
		{
			//本级的开始位置 和结束位置
			int nBeginNo = 0, nEndNo = 0;
			for (int i = 0; i < (int)vNums.size(); ++i)
			{
				if (i == 0)
				{
					nBeginNo = 0;
					nEndNo = vNums[0];
				}
				else
				{
					nBeginNo += vNums[i - 1];
					nEndNo += vNums[i];
				}

				if (nNo == i)
				{
					DataInfo = vData[nEndNo - 1];
					DataInfo.nJiaZaiOrXieZai = LOAD_VALUE;
					DataInfo.fLoadValue = (DataInfo.fLoadValue + vData[nEndNo].fLoadValue) / 2;
					vData.insert(vData.begin() + nEndNo, DataInfo);
					break;
				}
			}
		}
	}
	else
	{
		//本级的开始位置 和结束位置
		int nBeginNo = 0, nEndNo = 0;
		for (int i = 0; i < (int)vNums.size(); ++i)
		{
			if (i == 0)
			{
				nBeginNo = 0;
				nEndNo = vNums[0];
			}
			else
			{
				nBeginNo += vNums[i - 1];
				nEndNo += vNums[i];
			}

			if (nNo == i)
			{
				for (int k = nEndNo - 1; k >= nBeginNo; k--)
				{
					vData.erase(vData.begin() + k);
				}
				break;
			}
		}
	}

}

//插入一级
void CHZData::InsertMgGrade1(vector<DATA_INFO> &vData, int nNo, BOOL bAdd)
{
	int nBeginNo = 0, nEndNo = 0;
	GetMgDataNo(vData, nNo, nBeginNo, nEndNo);
	int nJiaZai = vData[nNo].nJiaZaiOrXieZai;
	if (bAdd)
	{
		vData.insert(vData.begin() + nEndNo + 1, vData[nNo]);
		vData[nEndNo + 1].nIdx++;
		for (int i = nEndNo + 2; i < (int)vData.size(); ++i)
		{
			if (nJiaZai != vData[i].nJiaZaiOrXieZai)
			{
				break;
			}
			vData[i].nIdx++;
		}
	}
	else
	{	
		for (int i = nBeginNo; i <= nEndNo; ++i)
		{
			vData.erase(vData.begin() + nBeginNo);
		}
		for (int i = nBeginNo; i < (int)vData.size(); ++i)
		{
			if (nJiaZai != vData[i].nJiaZaiOrXieZai)
			{
				break;
			}
			vData[i].nIdx--;
		}
	}
}

//插入一级
void CHZData::InsertGrade(int nNo, int nDataType, BOOL bAdd, BOOL bOriginal)
{
	vector<DATA_INFO> DataInfo = GetDataInfo();
	HZ_PROJECT_INFO ProInfo = GetProjectInfo();

	if (g_DataType == DATA_0)
	{	
		if (bOriginal)
		{
			InsertGrade1(DataInfo, nNo, nDataType, bAdd);
			ProInfo.nDataCnt = (int)DataInfo.size();
			SetDataInfo(DataInfo);
			SetProjectInfo(ProInfo);
		}
		else{
			InsertGrade1(m_vDataInfo, nNo, nDataType, bAdd);
			m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
		}
	}
	else if (g_DataType == DATA_1)
	{	
		if (bOriginal)
		{
			InsertMgGrade1(DataInfo, nNo, bAdd);
			ProInfo.nDataCnt = (int)DataInfo.size();
			SetDataInfo(DataInfo);
			SetProjectInfo(ProInfo);
		}
		else{
			InsertMgGrade1(m_vDataInfo, nNo, bAdd);
			m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
		}
	}	
	else if (g_DataType == DATA_2)
	{
		if (bOriginal)//原始记录
		{
			InsertSpOriGrade1(DataInfo, nNo, bAdd);
			ProInfo.nDataCnt = (int)DataInfo.size();
			SetDataInfo(DataInfo);
			SetProjectInfo(ProInfo);
		}
		else
		{
			InsertSpGrade1(m_vDataInfo, nNo, bAdd);
			m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
		}
	}
	else if (g_DataType == DATA_3)
	{
		if (bOriginal)//原始记录
		{
			InsertGrade1(DataInfo, nNo, nDataType, bAdd);
			ProInfo.nDataCnt = (int)DataInfo.size();
			SetDataInfo(DataInfo);
			SetProjectInfo(ProInfo);
		}
		else
		{
			InsertZphGrade1(m_vDataInfo, nNo, nDataType, bAdd);
			m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
		}
	}
	InitCalcData();
}

// void CHZData::InsertGrade(int nNo, int nDataType, BOOL bAdd)
// {
// 	vector<DATA_INFO> vAddInfo;
// 	vector<DATA_INFO> vDataInfo;
// 	int nId = 0;//本级ID
// 	BOOL bOpere = FALSE;
// 	BOOL bOver = FALSE;
// 	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
// 	{
// 		if (bAdd)
// 		{
// 			if (m_vDataInfo[i].nIdx == nNo && nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 			{
// 				bOpere = TRUE;
// 				vDataInfo.push_back(m_vDataInfo[i]);
// 				vAddInfo.push_back(m_vDataInfo[i]);
// 			}
// 			else
// 			{
// 				//遇到插入值，且不为空 则本级id++插入  
// 				if (bOpere && !vAddInfo.empty())
// 				{
// 					for (int n = 0; n < (int)vAddInfo.size(); ++n)
// 					{
// 						if (nDataType == vAddInfo[n].nJiaZaiOrXieZai)
// 						{
// 							vAddInfo[n].nIdx++;
// 						}
// 					
// 						vDataInfo.push_back(vAddInfo[n]);
// 					}
// 					vAddInfo.clear();
// 					if (nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 					{
// 						m_vDataInfo[i].nIdx++;
// 					}
// 					
// 					vDataInfo.push_back(m_vDataInfo[i]);
// 				}
// 				else if (bOpere) //遇到插入值，后续的本级id都++
// 				{
// 					if (nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 					{
// 						m_vDataInfo[i].nIdx++;
// 					}
// 					vDataInfo.push_back(m_vDataInfo[i]);
// 				}
// 				else
// 				{
// 					vDataInfo.push_back(m_vDataInfo[i]);
// 				}
// 			}
// 		}
// 		else
// 		{
// 			if (!bOver && m_vDataInfo[i].nIdx == nNo && nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 			{
// 				bOpere = TRUE;
// 				continue;
// 			}
// 			else
// 			{
// 				//bOpere == TRUE 表明已经遇到删除对象 则本级ID--
// 				if (bOpere)
// 				{
// 					if (nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 					{
// 						m_vDataInfo[i].nIdx--;
// 					}
// 					bOver = TRUE;
// 				}
// 				vDataInfo.push_back(m_vDataInfo[i]);
// 			}
// 		}
// 	}
// 	if (!vAddInfo.empty())
// 	{
// 		for (int n = 0; n < (int)vAddInfo.size(); ++n)
// 		{
// 			if (nDataType == vAddInfo[n].nJiaZaiOrXieZai)
// 			{
// 				vAddInfo[n].nIdx++;
// 			}
// 			vDataInfo.push_back(vAddInfo[n]);
// 		}
// 	}
// 
// 	//反赋值
// 	m_HZProInfo.nDataCnt = (int)vDataInfo.size();
// 	m_vDataInfo = vDataInfo;
// 
// 	InitCalcData();
// }

//锚杆已经全加/乘一固定值 bAdd :true +   False *
void CHZData::AddSpOneValue(vector<DATA_INFO> &vData, HZ_PROJECT_INFO HZProInfo, int nRow, int nCol, float fVal, BOOL bAdd)
{
	if (fVal > -EPSINON && fVal < EPSINON)
	{
		return;
	}
	//获取当数据所在行
	int nNo = GetSpDataRow(nRow, nCol);
	for (int i = 1; i < (int)vData.size(); ++i)
	{
		if (i < nNo)
		{
			continue;
		}
		if (bAdd)
		{
			vData[i].fWeiyiAvg += fVal;
			CheckValue(vData[i].fWeiyiAvg);
			for (int n = 0; n < 8; ++n)
			{
				if (HZProInfo.chChanelUsed[n] > 0)
				{
					vData[i].fWeiyi[n] += fVal;
					CheckValue(vData[i].fWeiyi[n]);
				}
			}
		}
		else
		{
			vData[i].fWeiyiAvg *= fVal;
			CheckValue(vData[i].fWeiyiAvg);
			for (int n = 0; n < 8; ++n)
			{
				if (HZProInfo.chChanelUsed[n] > 0)
				{
					vData[i].fWeiyi[n] *= fVal;
					CheckValue(vData[i].fWeiyi[n]);
				}
			}
		}
	}
}

//原始数据锚杆已经全加/乘一固定值 bAdd :true +   False *
void CHZData::AddSpOriOneValue(vector<DATA_INFO> &vData, HZ_PROJECT_INFO HZProInfo, int nRow, int nCol, float fVal, BOOL bAdd)
{
	if (fVal > -EPSINON && fVal < EPSINON)
	{
		return;
	}
	for (int i = 1; i < (int)vData.size(); ++i)
	{
		if (i < nRow)
		{
			continue;
		}
		if (bAdd)
		{
			vData[i].fWeiyiAvg += fVal;
			CheckValue(vData[i].fWeiyiAvg);
			for (int n = 0; n < 8; ++n)
			{
				if (HZProInfo.chChanelUsed[n] > 0)
				{
					vData[i].fWeiyi[n] += fVal;
					CheckValue(vData[i].fWeiyi[n]);
				}
			}
		}
		else
		{
			vData[i].fWeiyiAvg *= fVal;
			CheckValue(vData[i].fWeiyiAvg);
			for (int n = 0; n < 8; ++n)
			{
				if (HZProInfo.chChanelUsed[n] > 0)
				{
					vData[i].fWeiyi[n] *= fVal;
					CheckValue(vData[i].fWeiyi[n]);
				}
			}
		}
	}
}

//锚杆已经全加/乘一固定值 bAdd :true +   False *
void CHZData::AddMgOneValue(vector<DATA_INFO> &vData, HZ_PROJECT_INFO HZProInfo, int nRow, int Col, float fVal, BOOL bAdd)
{
	if (fVal > -EPSINON && fVal < EPSINON)
	{
		return;
	}
	for (int i = 1; i < (int)vData.size(); ++i)
	{
		if (i < nRow)
		{
			continue;
		}
		if (bAdd)
		{
			vData[i].fWeiyiAvg += fVal;
			CheckValue(vData[i].fWeiyiAvg);
			for (int n = 0; n < 8; ++n)
			{
				if (HZProInfo.chChanelUsed[n] > 0)
				{
					vData[i].fWeiyi[n] += fVal;
					CheckValue(vData[i].fWeiyi[n]);
				}
			}
		}
		else
		{
			vData[i].fWeiyiAvg *= fVal;
			CheckValue(vData[i].fWeiyiAvg);
			for (int n = 0; n < 8; ++n)
			{
				if (HZProInfo.chChanelUsed[n] > 0)
				{
					vData[i].fWeiyi[n] *= fVal;
					CheckValue(vData[i].fWeiyi[n]);
				}
			}
		}
	}
}

//已经全加/乘一固定值 bAdd :true +   False *
void CHZData::AddOneValue1(vector<DATA_INFO> &vData, HZ_PROJECT_INFO HZProInfo, int nRow, int Col, float fVal, int nDataType, BOOL bAdd)
{
	if (fVal > -EPSINON && fVal < EPSINON)
	{
		return;
	}
	BOOL bExist = FALSE;
	for (int i = 0; i < (int)vData.size(); ++i)
	{
		if (vData[i].nIdx == Col
			&& vData[i].nRecordId == nRow
			&& nDataType == vData[i].nJiaZaiOrXieZai)
		{
			bExist = TRUE;
		}

		if (bExist)
		{
			if (bAdd)
			{
				vData[i].fWeiyiAvg += fVal;
				CheckValue(vData[i].fWeiyiAvg);
				for (int n = 0; n < 8; ++n)
				{
					if (HZProInfo.chChanelUsed[n] > 0)
					{
						vData[i].fWeiyi[n] += fVal;
						CheckValue(vData[i].fWeiyi[n]);
					}
				}
			}
			else
			{
				vData[i].fWeiyiAvg *= fVal;
				CheckValue(vData[i].fWeiyiAvg);
				for (int n = 0; n < 8; ++n)
				{
					if (HZProInfo.chChanelUsed[n] > 0)
					{
						vData[i].fWeiyi[n] *= fVal;
						CheckValue(vData[i].fWeiyi[n]);
					}
				}
			}
		}
	}
}
//已经全加/乘一固定值 bAdd :true +   False *
void CHZData::AddZphOneValue1(vector<DATA_INFO> &vData, HZ_PROJECT_INFO HZProInfo, int nRow, int Col, float fVal, int nDataType, BOOL bAdd)
{
	if (fVal > -EPSINON && fVal < EPSINON)
	{
		return;
	}
	int nBenJi = Col / 2;
	BOOL bExist = FALSE;
	for (int i = 0; i < (int)vData.size(); ++i)
	{
		if (vData[i].nIdx == nBenJi
			&& vData[i].nRecordId == nRow
			&& nDataType == vData[i].nJiaZaiOrXieZai)
		{
			bExist = TRUE;
		}

		if (bExist)
		{
			if (bAdd)
			{
				if (Col % 2 == 0)	//下桩
				{
					vData[i].fWeiyiAvg += fVal;
					CheckValue(vData[i].fWeiyiAvg);
					for (int n = 0; n < 8; ++n)
					{
						if (HZProInfo.chChanelUsed[n] > 0)
						{
							vData[i].fWeiyi[n] += fVal;
							CheckValue(vData[i].fWeiyi[n]);
						}
					}
				}
				else{ //上桩
					vData[i].fShangZhuangShangBa += fVal;
					CheckValue(vData[i].fShangZhuangShangBa);
				}
				
			}
			else
			{
				if (Col % 2 == 0)	//下桩
				{
					vData[i].fWeiyiAvg *= fVal;
					CheckValue(vData[i].fWeiyiAvg);
					for (int n = 0; n < 8; ++n)
					{
						if (HZProInfo.chChanelUsed[n] > 0)
						{
							vData[i].fWeiyi[n] *= fVal;
							CheckValue(vData[i].fWeiyi[n]);
						}
					}
				}
				else{
					vData[i].fShangZhuangShangBa *= fVal;
					CheckValue(vData[i].fShangZhuangShangBa);
				}
				
			}
		}
	}
}

//反向
void CHZData::ReverseZphValue(vector<DATA_INFO> &vData)
{
	for (int i = 0; i < (int)vData.size(); ++i)
	{
		vData[i].fWeiyiAvg *= -1;
		CheckValue(vData[i].fWeiyiAvg);
		for (int n = 0; n < 8; ++n)
		{
			vData[i].fWeiyi[n] *= -1;
			CheckValue(vData[i].fWeiyi[n]);
		}

		vData[i].fShangZhuangShangBa *= -1;
		CheckValue(vData[i].fShangZhuangShangBa);
	}
	InitCalcData();
}


void CHZData::AddOneValue(int nRow, int Col, float fVal, int nDataType, BOOL bAdd, BOOL bOriginal)
{
	vector<DATA_INFO> DataInfo = GetDataInfo();
	HZ_PROJECT_INFO ProInfo = GetProjectInfo();
	if (g_DataType == DATA_0)
	{
		if (bOriginal)
		{
			AddOneValue1(DataInfo, ProInfo, nRow, Col, fVal, nDataType, bAdd);
			SetDataInfo(DataInfo);
		}
		else{
			AddOneValue1(m_vDataInfo, m_HZProInfo, nRow, Col, fVal, nDataType, bAdd);
		}		
	}
	else if (g_DataType == DATA_1)
	{
		if (bOriginal)
		{
			AddMgOneValue(DataInfo, ProInfo, nRow, Col, fVal, bAdd);
			SetDataInfo(DataInfo);
		}
		else{
			AddMgOneValue(m_vDataInfo, m_HZProInfo, nRow, Col, fVal, bAdd);
		}
	}
	else if (g_DataType == DATA_2)
	{
		if (bOriginal)
		{
			AddSpOriOneValue(DataInfo, ProInfo, nRow, Col, fVal, bAdd);	
			SetDataInfo(DataInfo);
		}
		else
		{
			AddSpOneValue(m_vDataInfo, m_HZProInfo, nRow, Col, fVal, bAdd);
		}
	}
	else if (g_DataType == DATA_3)
	{
		if (bOriginal)
		{
			AddOneValue1(DataInfo, ProInfo, nRow, Col, fVal, nDataType, bAdd);	
			SetDataInfo(DataInfo);
		}
		else
		{
			AddZphOneValue1(m_vDataInfo, m_HZProInfo, nRow, Col, fVal, nDataType, bAdd);
		}
	}
	InitCalcData();
}

// void CHZData::AddOneValue(int nRow, int Col, float fVal, int nDataType, BOOL bAdd)
// {
// 	if (fVal > -EPSINON && fVal < EPSINON)
// 	{
// 		return;
// 	}
// 	BOOL bExist = FALSE;
// 	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
// 	{
// 		if (m_vDataInfo[i].nIdx == Col
// 			&& m_vDataInfo[i].nRecordId == nRow
// 			&& nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 		{
// 			bExist = TRUE;
// 		}
// 
// 		if (bExist)
// 		{
// 			if (bAdd)
// 			{
// 				m_vDataInfo[i].fWeiyiAvg += fVal;
// 				CheckValue(m_vDataInfo[i].fWeiyiAvg);
// 				for (int n = 0; n < 8; ++n)
// 				{
// 					if (m_HZProInfo.chChanelUsed[n] > 0)
// 					{
// 						m_vDataInfo[i].fWeiyi[n] += fVal;
// 						CheckValue(m_vDataInfo[i].fWeiyi[n]);
// 					}
// 				}
// 			}
// 			else
// 			{
// 				m_vDataInfo[i].fWeiyiAvg *= fVal;
// 				CheckValue(m_vDataInfo[i].fWeiyiAvg);
// 				for (int n = 0; n < 8; ++n)
// 				{
// 					if (m_HZProInfo.chChanelUsed[n] > 0)
// 					{
// 						m_vDataInfo[i].fWeiyi[n] *= fVal;
// 						CheckValue(m_vDataInfo[i].fWeiyi[n]);
// 					}
// 				}
// 			}
// 		}
// 	}
// 	InitCalcData();
// }


void CHZData::AddOneValueOther1(vector<DATA_INFO> &vData, int nRow, int Col, int nType, float fVal, int nDataType, BOOL bAdd)
{
	BOOL bExist = FALSE;
	USES_CONVERSION;
	CString strTime(L"");
	COleDateTime   tm;
	for (int i = 0; i < (int)vData.size(); ++i)
	{
		if (vData[i].nIdx == Col
			&& vData[i].nRecordId == nRow
			&& nDataType == vData[i].nJiaZaiOrXieZai)
		{
			bExist = TRUE;
		}

		if (bExist)
		{
			if (bAdd)
			{
				if (nType == 1)
				{
					vData[i].fLoadValue += fVal;
				}
				else if (nType == 2)
				{
					vData[i].fCurLoad += fVal;
				}
				else if (nType == 3)
				{
					vData[i].fCurYouya += fVal;
				}
				else if (nType == 4)
				{
					strTime = vData[i].chRecordTime;
					tm.ParseDateTime(strTime);
					CTime ct(tm.GetYear(), tm.GetMonth(), tm.GetDay(), tm.GetHour(), tm.GetMinute(), tm.GetSecond());
					ct += (int(fVal));
					strTime = ct.Format(L"%Y-%m-%d %H:%M:%S");
					strcpy_s(vData[i].chRecordTime, sizeof(vData[i].chRecordTime), W2A(strTime));
				}
				else if (nType == 5 && g_DataType == DATA_3)
				{
					vData[i].fShangZhuangShangBa += fVal;
				}
			}
			else
			{
				if (nType == 1)
				{
					vData[i].fLoadValue *= fVal;
				}
				else if (nType == 2)
				{
					vData[i].fCurLoad *= fVal;
				}
				else if (nType == 3)
				{
					vData[i].fCurYouya *= fVal;
				}
				else if (nType == 5 && g_DataType == DATA_3)
				{
					vData[i].fShangZhuangShangBa *= fVal;
				}
			}
		}
	}
}

CString CHZData::GetTimeAdd(char *chTime, int addSec)
{
	CString strTime(L"");
	USES_CONVERSION;
	COleDateTime   tm;
	strTime = chTime;
	tm.ParseDateTime(strTime);
	CTime ct(tm.GetYear(), tm.GetMonth(), tm.GetDay(), tm.GetHour(), tm.GetMinute(), tm.GetSecond());
	ct += (int(addSec));
	strTime = ct.Format(L"%Y-%m-%d %H:%M:%S");
	return strTime;
}


//已经全加/乘一固定值 bAdd :true +   False *   nType 1：加载级 2：实测荷载 3：实测油压
void CHZData::AddMgOneValueOther1(vector<DATA_INFO> &vData, int nRow, int Col, int nType, float fVal, BOOL bAdd)
{
	BOOL bExist = FALSE;
	USES_CONVERSION;
	CString strTime(L"");
	COleDateTime   tm;
	for (int i = 1; i < (int)vData.size(); ++i)
	{
		if (i < nRow)
		{
			continue;
		}
		if (bAdd)
		{
			if (nType == 1)
			{
				vData[i].fLoadValue += fVal;
			}
			else if (nType == 2)
			{
				vData[i].fCurLoad += fVal;
			}
			else if (nType == 3)
			{
				vData[i].fCurYouya += fVal;
			}
			else if (nType == 4)
			{
				strTime = vData[i].chRecordTime;
				tm.ParseDateTime(strTime);
				CTime ct(tm.GetYear(), tm.GetMonth(), tm.GetDay(), tm.GetHour(), tm.GetMinute(), tm.GetSecond());
				ct += (int(fVal));
				strTime = ct.Format(L"%Y-%m-%d %H:%M:%S");
				strcpy_s(vData[i].chRecordTime, sizeof(vData[i].chRecordTime), W2A(strTime));
			}
		}
		else
		{
			if (nType == 1)
			{
				vData[i].fLoadValue *= fVal;
			}
			else if (nType == 2)
			{
				vData[i].fCurLoad *= fVal;
			}
			else if (nType == 3)
			{
				vData[i].fCurYouya *= fVal;
			}
		}
	}
}

//已经全加/乘一固定值 bAdd :true +   False *   nType 1：加载级 2：实测荷载 3：实测油压
void CHZData::AddSpOneValueOther1(vector<DATA_INFO> &vData, int nRow, int Col, int nType, float fVal, BOOL bAdd)
{
	BOOL bExist = FALSE;
	USES_CONVERSION;
	CString strTime(L"");
	COleDateTime   tm;
	for (int i = 1; i < (int)vData.size(); ++i)
	{
		if (i < nRow)
		{
			continue;
		}
		if (bAdd)
		{
			if (nType == 1)
			{
				vData[i].fLoadValue += fVal;
			}
			else if (nType == 2)
			{
				vData[i].fCurLoad += fVal;
			}
			else if (nType == 3)
			{
				vData[i].fCurYouya += fVal;
			}
			else if (nType == 4)
			{
				strTime = vData[i].chRecordTime;
				tm.ParseDateTime(strTime);
				CTime ct(tm.GetYear(), tm.GetMonth(), tm.GetDay(), tm.GetHour(), tm.GetMinute(), tm.GetSecond());
				ct += (int(fVal));
				strTime = ct.Format(L"%Y-%m-%d %H:%M:%S");
				strcpy_s(vData[i].chRecordTime, sizeof(vData[i].chRecordTime), W2A(strTime));
			}
			else if (nType == 5)
			{
				vData[i].fShangZhuangShangBa += fVal;
			}
		}
		else
		{
			if (nType == 1)
			{
				vData[i].fLoadValue *= fVal;
			}
			else if (nType == 2)
			{
				vData[i].fCurLoad *= fVal;
			}
			else if (nType == 3)
			{
				vData[i].fCurYouya *= fVal;
			}
			else if (nType == 5)
			{
				vData[i].fShangZhuangShangBa *= fVal;
			}
		}
	}
}


//已经全加/乘一固定值 bAdd :true +   False *   nType 1：加载级 2：实测荷载 3：实测油压 4:时间  14：备注后者上桩上拔
void CHZData::AddOneValueOther(int nRow, int Col, int nType, float fVal, int nDataType, BOOL bAdd, BOOL bOriginal)
{
	vector<DATA_INFO> DataInfo = GetDataInfo();
	if (g_DataType == DATA_0|| g_DataType == DATA_3)
	{
		if (bOriginal)
		{
			AddOneValueOther1(DataInfo, nRow, Col, nType, fVal, nDataType, bAdd);
			SetDataInfo(DataInfo);
		}
		else{
			AddOneValueOther1(m_vDataInfo, nRow, Col, nType, fVal, nDataType, bAdd);
		}
	}
	else if (g_DataType == DATA_1)
	{	
		if (bOriginal)
		{
			AddMgOneValueOther1(DataInfo, nRow, Col, nType, fVal, bAdd);
			SetDataInfo(DataInfo);
		}
		else{
			AddMgOneValueOther1(m_vDataInfo, nRow, Col, nType, fVal, bAdd);
		}
	}
	else if (g_DataType == DATA_2)
	{
		if (bOriginal)
		{
			AddSpOneValueOther1(DataInfo, nRow, Col, nType, fVal, bAdd);
			SetDataInfo(DataInfo);
		}
		else
		{
			AddSpOneValueOther1(m_vDataInfo, nRow, Col, nType, fVal, bAdd);
		}
	}
	if (bOriginal && nType == 4)
	{
		ReCalcOriTimeGap(DataInfo);
		SetDataInfo(DataInfo);
	}
	InitCalcData();
}


// void CHZData::AddOneValueOther(int nRow, int Col, int nType, float fVal, int nDataType, BOOL bAdd)
// {
// 	BOOL bExist = FALSE;
// 	USES_CONVERSION;
// 	CString strTime(L"");
// 	COleDateTime   tm;
// 	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
// 	{
// 		if (m_vDataInfo[i].nIdx == Col
// 			&& m_vDataInfo[i].nRecordId == nRow
// 			&& nDataType == m_vDataInfo[i].nJiaZaiOrXieZai)
// 		{
// 			bExist = TRUE;
// 		}
// 
// 		if (bExist)
// 		{
// 			if (bAdd)
// 			{
// 				if (nType == 1)
// 				{
// 					m_vDataInfo[i].fLoadValue += fVal;
// 				}
// 				else if (nType == 2)
// 				{
// 					m_vDataInfo[i].fCurLoad += fVal;
// 				}
// 				else if (nType == 3)
// 				{
// 					m_vDataInfo[i].fCurYouya += fVal;
// 				}
// 				else if (nType == 4)
// 				{
// 					strTime = m_vDataInfo[i].chRecordTime;
// 					tm.ParseDateTime(strTime);
// 					CTime ct(tm.GetYear(), tm.GetMonth(), tm.GetDay(), tm.GetHour(), tm.GetMinute(), tm.GetSecond());
// 					ct += (int(fVal));
// 					strTime = ct.Format(L"%Y-%m-%d %H:%M:%S");
// 					strcpy_s(m_vDataInfo[i].chRecordTime, sizeof(m_vDataInfo[i].chRecordTime), W2A(strTime));
// 				}
// 			}
// 			else
// 			{
// 				if (nType == 1)
// 				{
// 					m_vDataInfo[i].fLoadValue *= fVal;
// 				}
// 				else if (nType == 2)
// 				{
// 					m_vDataInfo[i].fCurLoad *= fVal;
// 				}
// 				else if (nType == 3)
// 				{
// 					m_vDataInfo[i].fCurYouya *= fVal;
// 				}
// 			}
// 		}
// 	}
// 	InitCalcData();
// }

//原始记录表中 根据序号获取本级ID和序号和加载还是卸载
void CHZData::GetId(int nNo, int &nBenJiId, int &nTimeId, int &nJiaZaiOrXieZai)
{
	vector<DATA_INFO> DataInfo = GetDataInfo();
	if (!g_bInitData || nNo >= (int)DataInfo.size())
	{
		return;
	}
	nBenJiId = DataInfo[nNo].nIdx;
	nTimeId = DataInfo[nNo].nRecordId;
	nJiaZaiOrXieZai = DataInfo[nNo].nJiaZaiOrXieZai;
}
// void CHZData::GetId(int nNo, int &nBenJiId, int &nTimeId, int &nJiaZaiOrXieZai)
// {
// 	if (!g_bInitData || nNo >= (int)m_vDataInfo.size())
// 	{
// 		return;
// 	}
// 	nBenJiId = m_vDataInfo[nNo].nIdx;
// 	nTimeId = m_vDataInfo[nNo].nRecordId;
// 	nJiaZaiOrXieZai = m_vDataInfo[nNo].nJiaZaiOrXieZai;
// }

BOOL CHZData::ChangeUnit_old(char chUnit)
{
	if (!g_bInitData)
	{
		return FALSE;
	}
	float fArea = m_HZProInfo_Old.fPlateArea; //承压板面积 平方米
	if (fArea >= -EPSINON && fArea <= EPSINON)
	{
		return FALSE;
	}
	m_HZProInfo_Old.chUnit = chUnit;
	BOOL bKN = FALSE;
	if (m_HZProInfo_Old.chUnit == 0) //kN
	{
		//乘以承压板面积
		bKN = TRUE;
	}

	for (int i = 0; i < m_HZProInfo_Old.nSignCnts; ++i)
	{
		if (bKN)
		{
			m_HZProInfo_Old.fSignHeZai[i] *= fArea;
			m_HZProInfo_Old.fSignWeiyi[i] *= fArea;
		}
		else
		{
			m_HZProInfo_Old.fSignHeZai[i] /= fArea;
			m_HZProInfo_Old.fSignWeiyi[i] /= fArea;
		}
	}

	for (int i = 0; i < (int)m_vDataInfo_Old.size(); ++i)
	{
		if (bKN)
		{
			m_vDataInfo_Old[i].fLoadValue *= fArea;
			m_vDataInfo_Old[i].fCurLoad *= fArea;
		}
		else
		{
			m_vDataInfo_Old[i].fLoadValue /= fArea;
			m_vDataInfo_Old[i].fCurLoad /= fArea;
		}
	}
	return TRUE;
}
//改变单位给数值带来的改变
BOOL CHZData::ChangeUnit(char chUnit)
{
	if (!g_bInitData)
	{
		return FALSE;
	}
	//原始记录也修改
	//ChangeUnit_old(chUnit);

	float fArea = m_HZProInfo.fPlateArea; //承压板面积 平方米
	if (fArea >= -EPSINON && fArea <= EPSINON)
	{
		return FALSE;
	}
	m_HZProInfo.chUnit = chUnit;
	BOOL bKN = FALSE;
	if (m_HZProInfo.chUnit == 0) //kN
	{
		//乘以承压板面积
		bKN = TRUE;
	}

	
	for (int i = 0; i < m_HZProInfo.nSignCnts; ++i)
	{
		if (bKN)
		{
			m_HZProInfo.fSignHeZai[i] *= fArea;
			m_HZProInfo.fSignWeiyi[i] *= fArea;
		}
		else
		{
			m_HZProInfo.fSignHeZai[i] /= fArea;
			m_HZProInfo.fSignWeiyi[i] /= fArea;
		}
	}

	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (bKN)
		{
			m_vDataInfo[i].fLoadValue *= fArea;
			m_vDataInfo[i].fCurLoad *= fArea;
		}
		else
		{
			m_vDataInfo[i].fLoadValue /= fArea;
			m_vDataInfo[i].fCurLoad /= fArea;
		}
	}
	if (bKN)
	{
		g_CoordSet.fXMax *= fArea;
	}
	else
	{
		g_CoordSet.fXMax /= fArea;
	}
	InitCalcData();
	return TRUE;
}

//移动曲线改变值
int CHZData::MoveCurve(int &nNo, float fVal, CURVE_TYPE CurveType, ZphPos zPos)
{
	if (!g_bInitData)
	{
		return -1;
	}
	int nBenJiId = 0;
	int nTimeId = 0; 
	int nJiaZaiOrXieZai = 3;
	if (CurveType == CU_Q_s || CurveType == CU_ZPH_QS)
	{
		if (nNo >= 0 && nNo < (int)m_vSummaryData.size())
		{
			nJiaZaiOrXieZai = m_vSummaryData[nNo].nJiaZaiOrXieZai;
			nBenJiId = m_vSummaryData[nNo].nBenJiId;

			MoveModifyVal(nBenJiId, nJiaZaiOrXieZai, fVal, zPos);
		}
	}
	else if (CurveType == CU_s_lgQ || CurveType == CU_ZPH_slgQ)
	{
		if (nNo >= 0 && nNo < (int)m_vLoadValue.size())
		{
			nJiaZaiOrXieZai = LOAD_VALUE;
			nBenJiId = nNo;
			MoveModifyVal(nBenJiId, nJiaZaiOrXieZai, fVal, zPos);
		}
	}
	else if (CurveType == CU_s_lgt || CurveType == CU_ZPH_slgt)
	{
		nJiaZaiOrXieZai = LOAD_VALUE;
		MoveModifyValBy_s_lgt(nNo, nJiaZaiOrXieZai, fVal, zPos);
	}
	else if (CurveType == CU_MG_Q_s)
	{
		MoveMgModifyVal(nNo, fVal);
	}
	return nJiaZaiOrXieZai;
}

//根据选中的圆圈序号获取s-lgt中的本级序号，时间序号，数据类型
void CHZData::GetSlgtId(int nNo, int &nBenJiId, int &nTimeId, int &nDataType)
{
	if (!g_bInitData || -1 == nNo)
	{
		return;
	}
	int nCnt = 0;
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (m_vDataInfo[i].nRecordId > 0)
		{
			if (nCnt == nNo)
			{
				nBenJiId = m_vDataInfo[i].nIdx;
				nTimeId = m_vDataInfo[i].nRecordId;
				nDataType = m_vDataInfo[i].nJiaZaiOrXieZai;
			}
			nCnt++;
		}
	}
}

//移动曲线改变统计值
void CHZData::MoveModifyValBy_s_lgt(int &nNo, int nDataType, float fVal, ZphPos zPos)
{
	if (!g_bInitData)
	{
		return;
	}
	//修改工程中值
	int nCnt = 0; 
	int nBenJiId = 0;
	BOOL bFind = FALSE;
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (nBenJiId != m_vDataInfo[i].nIdx)
		{
			//如果上一级是最后一个 则他的下一个本级第一个值也要更改
			if (bFind)
			{
				if (zPos == POS_Down)
				{
					m_vDataInfo[i].fWeiyiAvg += fVal;
					CheckValue(m_vDataInfo[i].fWeiyiAvg);
					for (int n = 0; n < 8; ++n)
					{
						if (m_HZProInfo.chChanelUsed[n] > 0)
						{
							m_vDataInfo[i].fWeiyi[n] += fVal;
							CheckValue(m_vDataInfo[i].fWeiyi[n]);
						}
					}
				}
				else if (zPos == POS_Up)
				{
					m_vDataInfo[i].fShangZhuangShangBa += fVal;
					CheckValue(m_vDataInfo[i].fShangZhuangShangBa);
				}				
				break;
			}
		}
		if (m_vDataInfo[i].nRecordId > 0)
		{
			if (bFind)
			{
				//表明第二次进入 则退出
				break;
			}
			bFind = FALSE;
			if (nCnt == nNo)
			{
				nBenJiId = m_vDataInfo[i].nIdx;
				bFind = TRUE;
				if (zPos == POS_Down)
				{
					m_vDataInfo[i].fWeiyiAvg += fVal;
					CheckValue(m_vDataInfo[i].fWeiyiAvg);
					for (int n = 0; n < 8; ++n)
					{
						if (m_HZProInfo.chChanelUsed[n] > 0)
						{
							m_vDataInfo[i].fWeiyi[n] += fVal;
							CheckValue(m_vDataInfo[i].fWeiyi[n]);
						}
					}
				}
				else if (zPos == POS_Up)
				{
					m_vDataInfo[i].fShangZhuangShangBa += fVal;
					CheckValue(m_vDataInfo[i].fShangZhuangShangBa);
				}				
			}
			nCnt++;
		}
	}

	nCnt = 0;
	bFind = FALSE;
	int k = 0;
	for (int i = 0; i < (int)m_vLoadValue.size(); ++i)
	{
		if (bFind)
		{
			if (zPos == POS_Down)
			{
				m_vLoadData[0].vfWeiyi[i] += fVal;
			}
			else if (zPos == POS_Up)
			{
				m_vLoadData[0].vfUpWeiyi[i] += fVal;
			}			
			break;
		}
		for (k = 0; k < (int)m_vLoadData.size(); ++k)
		{
			bFind = FALSE;
			if (k > 0  && m_vLoadData[k].vExist[i])
			{
				if (nCnt == nNo)
				{
					if (zPos == POS_Down)
					{
						m_vLoadData[k].vfWeiyi[i] += fVal;
					}
					else if (zPos == POS_Up)
					{
						m_vLoadData[k].vfUpWeiyi[i] += fVal;
					}					
					bFind = TRUE;
				}
				nCnt++;
			}
		}
	}
	//判断当前是不是加载级最后一个
	if (bFind && !m_vLoadValue.empty() && !m_vLoadData.empty())
	{
		if (!m_vLoadOffData.empty())
		{
			if (zPos == POS_Down)
			{
				m_vLoadOffData[0].vfWeiyi[0] += fVal;
			}
			else if (zPos == POS_Up)
			{
				m_vLoadOffData[0].vfUpWeiyi[0] += fVal;
			}			
		}
	}
	//计算汇总值
	CalcSummaryDataNew(m_vSummaryData);
	nNo = nBenJiId;
}

//移动曲线改变统计值
void CHZData::MoveModifyVal(int nBenJiId, int nDataType, float fVal, ZphPos zPos)
{
	//修改工程中值
	if (!g_bInitData)
	{
		return;
	}
	BOOL bCalc = FALSE;
	BOOL bFirst = FALSE;
	//本级中第一个值不改，后一级中第一个改
	for (int i = 0; i < (int)m_vDataInfo.size(); ++i)
	{
		if (m_vDataInfo[i].nIdx == nBenJiId && m_vDataInfo[i].nJiaZaiOrXieZai == nDataType)
		{
			if (!bFirst)
			{
				bFirst = TRUE;
				continue;
			}
			bCalc = TRUE;
			if (zPos == POS_Down)
			{
				m_vDataInfo[i].fWeiyiAvg += fVal;
				CheckValue(m_vDataInfo[i].fWeiyiAvg);
				for (int n = 0; n < 8; ++n)
				{
					if (m_HZProInfo.chChanelUsed[n] > 0)
					{
						m_vDataInfo[i].fWeiyi[n] += fVal;
						CheckValue(m_vDataInfo[i].fWeiyi[n]);
					}
				}
			}
			else if (zPos == POS_Up)
			{
				m_vDataInfo[i].fShangZhuangShangBa += fVal;
				CheckValue(m_vDataInfo[i].fShangZhuangShangBa);
			}			
			continue;
		}
		if (bCalc)
		{
			if (zPos == POS_Down)
			{
				m_vDataInfo[i].fWeiyiAvg += fVal;
				CheckValue(m_vDataInfo[i].fWeiyiAvg);
				for (int n = 0; n < 8; ++n)
				{
					if (m_HZProInfo.chChanelUsed[n] > 0)
					{
						m_vDataInfo[i].fWeiyi[n] += fVal;
						CheckValue(m_vDataInfo[i].fWeiyi[n]);
					}
				}
			}
			else if (zPos == POS_Up)
			{
				m_vDataInfo[i].fShangZhuangShangBa += fVal;
				CheckValue(m_vDataInfo[i].fShangZhuangShangBa);
			}
			break;
		}
	}

	if (nDataType == LOAD_VALUE && bCalc)
	{
		for (int i = 0; i < (int)m_vLoadData.size(); ++i)
		{
			if (i != 0 && m_vLoadData[i].vExist[nBenJiId])
			{
				if (zPos == POS_Down)
				{
					m_vLoadData[i].vfWeiyi[nBenJiId] += fVal;
					CheckValue(m_vLoadData[i].vfWeiyi[nBenJiId]);
				}
				else if (zPos == POS_Up)
				{
					m_vLoadData[i].vfUpWeiyi[nBenJiId] += fVal;
					CheckValue(m_vLoadData[i].vfUpWeiyi[nBenJiId]);
				}				
			}
		}
		//判断当前是不是加载级最后一个
		if (nBenJiId == (int)m_vLoadValue.size() - 1)
		{
			if (!m_vLoadOffData.empty())
			{
				if (zPos == POS_Down)
				{
					m_vLoadOffData[0].vfWeiyi[0] += fVal;
					CheckValue(m_vLoadOffData[0].vfWeiyi[0]);
				}
				else if (zPos == POS_Up)
				{
					m_vLoadOffData[0].vfUpWeiyi[0] += fVal;
					CheckValue(m_vLoadOffData[0].vfUpWeiyi[0]);
				}				
			}
		}
		else
		{
			if (zPos == POS_Down)
			{
				m_vLoadData[0].vfWeiyi[nBenJiId + 1] += fVal;
				CheckValue(m_vLoadData[0].vfWeiyi[nBenJiId + 1]);
			}
			else if (zPos == POS_Up)
			{
				m_vLoadData[0].vfUpWeiyi[nBenJiId + 1] += fVal;
				CheckValue(m_vLoadData[0].vfUpWeiyi[nBenJiId + 1]);
			}			
		}
	}
	else if (nDataType == LOADOFF_VALUE && bCalc)
	{
		for (int i = 0; i < (int)m_vLoadOffData.size(); ++i)
		{
			if (i != 0 && m_vLoadOffData[i].vExist[nBenJiId])
			{
				if (zPos == POS_Down)
				{
					m_vLoadOffData[i].vfWeiyi[nBenJiId] += fVal;
					CheckValue(m_vLoadOffData[i].vfWeiyi[nBenJiId]);
				}
				else if (zPos == POS_Up)
				{
					m_vLoadOffData[i].vfUpWeiyi[nBenJiId] += fVal;
					CheckValue(m_vLoadOffData[i].vfUpWeiyi[nBenJiId]);
				}				
			}
		}
		//判断当前是不是加载级最后一个
		if (!m_vLoadOffData.empty() && nBenJiId != (int)m_vLoadOffData[0].vfWeiyi.size() - 1)
		{
			if (zPos == POS_Down)
			{
				m_vLoadOffData[0].vfWeiyi[nBenJiId + 1] += fVal;
				CheckValue(m_vLoadOffData[0].vfWeiyi[nBenJiId + 1]);
			}
			else if (zPos == POS_Up)
			{
				m_vLoadOffData[0].vfUpWeiyi[nBenJiId + 1] += fVal;
				CheckValue(m_vLoadOffData[0].vfUpWeiyi[nBenJiId + 1]);
			}			
		}
	}

	//计算汇总值
	CalcSummaryDataNew(m_vSummaryData);
}

//移动曲线改变统计值
void CHZData::MoveMgModifyVal(int nNo, float fVal)
{
	int nId = m_vDataInfo[0].nIdx;
	int nJaiZai = m_vDataInfo[0].nJiaZaiOrXieZai;
	int nCnt = 0;
	for (int i = 1; i < (int)m_vDataInfo.size(); ++i)
	{
		if (nId != m_vDataInfo[i].nIdx || nJaiZai != m_vDataInfo[i].nJiaZaiOrXieZai)
		{
			nCnt++;
			nId = m_vDataInfo[i].nIdx;
			nJaiZai = m_vDataInfo[i].nJiaZaiOrXieZai;
		}
		if (nCnt == nNo)
		{
			m_vDataInfo[i].fWeiyiAvg += fVal;
			CheckValue(m_vDataInfo[i].fWeiyiAvg);
			for (int n = 0; n < 8; ++n)
			{
				if (m_HZProInfo.chChanelUsed[n] > 0)
				{
					m_vDataInfo[i].fWeiyi[n] += fVal;
					CheckValue(m_vDataInfo[i].fWeiyi[n]);
				}
			}
		}
	}
	InitCalcData();
}

//根据当前序号计算出当前序号
void CHZData::GetMgDataNo(vector<DATA_INFO> vDataInfo, int nNo, int &nBeginNo, int &nEndNo)
{
	if (vDataInfo.empty() || nNo < 0 || nNo >= (int)vDataInfo.size())
	{
		return;
	}
	nBeginNo = nNo;
	nEndNo = nNo;
	int nBenji = vDataInfo[nNo].nIdx;
	int nJiaZai = vDataInfo[nNo].nJiaZaiOrXieZai;

	BOOL bFind = FALSE;
	for (int i = nNo + 1; i < (int)vDataInfo.size(); ++i)
	{
		if (nBenji != vDataInfo[i].nIdx || nJiaZai != vDataInfo[i].nJiaZaiOrXieZai || i == (int)vDataInfo.size() - 1)
		{
			nEndNo = i - 1;
			break;
		}
	}
	for (int i = nNo - 1; i >= 0; i--)
	{
		if (nBenji != vDataInfo[i].nIdx || nJiaZai != vDataInfo[i].nJiaZaiOrXieZai || i == 0)
		{
			nBeginNo = i + 1;
			break;
		}
	}
}

//根据Id 序号 获取vector 序号
int CHZData::GetMgVectorNo(int nIdNo)
{
	int nId = m_vDataInfo[0].nIdx;
	int nJaiZai = m_vDataInfo[0].nJiaZaiOrXieZai;
	int nCnt = 0;
	int i = 0;
	for (i = 1; i < (int)m_vDataInfo.size(); ++i)
	{
		if (nId != m_vDataInfo[i].nIdx || nJaiZai != m_vDataInfo[i].nJiaZaiOrXieZai)
		{
			nCnt++;
			nId = m_vDataInfo[i].nIdx;
			nJaiZai = m_vDataInfo[i].nJiaZaiOrXieZai;

			if (nCnt == nIdNo)
			{
				break;
			}
		}
	}
	return i;
}

//修改Mg数据
int CHZData::ModifytMgData(int nNo, int nCol, float fVal, BOOL bMore)
{
	if (nNo >= (int)m_vDataInfo.size())
	{
		return 0;
	}
	int nId = 0;
	if (1 == nCol) //修改拉力值
	{
		//先根据当前序号，计算出开始序号和结束序号
		int nBeginNo = 0, nEndNo = 0;
		GetMgDataNo(m_vDataInfo, nNo, nBeginNo, nEndNo);
		for (int i = nBeginNo; i <= nEndNo; ++i)
		{
			m_vDataInfo[i].fLoadValue = fVal;
		}

		//获取在m_vvMgXQBData 中的序号
		int nCnt = m_vvMgXQBData[0].size();
		for (int i = 1; i < (int)m_vvMgXQBData.size(); ++i)
		{
			if (nNo + 1 > nCnt && nNo + 1 < nCnt + (int)m_vvMgXQBData[i].size())
			{
				nId = i;
				break;
			}
			nCnt += (int)m_vvMgXQBData[i].size();
		}
		InitCalcData();
	}
	else if (5 == nCol) //修改位移值
	{
		//获取在m_vvMgXQBData 中的序号
		int nCnt = m_vvMgXQBData[0].size();
		for (int i = 1; i < (int)m_vvMgXQBData.size(); ++i)
		{
			if (nNo + 1 > nCnt && nNo + 1 < nCnt + (int)m_vvMgXQBData[i].size())
			{
				nId = i;
				break;
			}
			nCnt += (int)m_vvMgXQBData[i].size();
		}

		if (bMore) //多行修改
		{
			int nBeginNo = 0, nEndNo = 0;
			GetMgDataNo(m_vDataInfo, nNo, nBeginNo, nEndNo);
			for (int i = nBeginNo; i <= nEndNo; ++i)
			{
				m_vDataInfo[i].fWeiyiAvg += fVal;
				CheckValue(m_vDataInfo[i].fWeiyiAvg);
				for (int j = 0; j < 8; ++j)
				{
					if (m_HZProInfo.chChanelUsed[j] > 0)
					{
						m_vDataInfo[i].fWeiyi[j] += fVal;
						CheckValue(m_vDataInfo[i].fWeiyi[j]);
					}
				}
			}
		}
		else
		{
			m_vDataInfo[nNo].fWeiyiAvg += fVal;
			CheckValue(m_vDataInfo[nNo].fWeiyiAvg);
			for (int i = 0; i < 8; ++i)
			{
				if (m_HZProInfo.chChanelUsed[i] > 0)
				{
					m_vDataInfo[nNo].fWeiyi[i] += fVal;
					CheckValue(m_vDataInfo[nNo].fWeiyi[i]);
				}
			}
		}
		InitCalcData();
	}
	return nId;
}

//重新计算原始记录时间间隔
void CHZData::ReCalcOriTimeGap(vector<DATA_INFO> &DataInfo)
{
	if (!g_bInitData)
	{
		return;
	}
	COleDateTime   tm;
	COleDateTime   tlst;
	int nLastH = 0;
	int nLastM = 0;
	int nLoatD = 0;
	int nHour = 0; 
	int nMin = 0;
	int nDay = 0;

	for (int i = 1; i < (int)DataInfo.size(); ++i)
	{
		tm.ParseDateTime(CString(DataInfo[i].chRecordTime));
		nHour = tm.GetHour();
		nMin = tm.GetMinute();

		tlst.ParseDateTime(CString(DataInfo[i - 1].chRecordTime));
		nLastH = tlst.GetHour();
		nLastM = tlst.GetMinute();

		DataInfo[i].nTimeGap = nHour * 60 + nMin - nLastH * 60 - nLastM;
		if (DataInfo[i].nTimeGap < 0){
			DataInfo[i].nTimeGap = nHour * 60 + nMin + (24 * 60 - nLastH * 60 - nLastM);
		}
	}
}

//水平记录修改加载级
void CHZData::ModifySpJiLuVal(int nNo, int nCol, CString strVal)
{
	if (!g_bInitData || nNo >= (int)m_vDataInfo.size() - 1 || nNo < 0)
	{
		return;
	}

	float fVal = 0.0f;
	if (nCol == 1)
	{
		USES_CONVERSION;
		strcpy_s(m_vDataInfo[nNo].chRecordTime,
			sizeof(m_vDataInfo[nNo].chRecordTime), W2A(strVal));
	}
	else if (nCol == 3)
	{
		fVal = float(_ttof(strVal));
		m_vDataInfo[nNo].fShangZhuangShangBa = fVal;
	}
	else if (nCol == 4)
	{
		fVal = float(_ttof(strVal));
		float fGap = fVal - m_vDataInfo[nNo].fWeiyiAvg;
		m_vDataInfo[nNo].fWeiyiAvg = fVal;

		CheckValue(m_vDataInfo[nNo].fWeiyiAvg);
		for (int i = 0; i < 8; ++i)
		{
			if (m_HZProInfo.chChanelUsed[i] > 0)
			{
				m_vDataInfo[nNo].fWeiyi[i] += fGap;
				CheckValue(m_vDataInfo[nNo].fWeiyi[i]);
			}
		}
	}
	else if (nCol == 5)
	{
		fVal = float(_ttof(strVal));
		m_vDataInfo[nNo + 1].fShangZhuangShangBa = fVal;
	}
	else if (nCol == 6)
	{
		fVal = float(_ttof(strVal));
		float fGap = fVal - m_vDataInfo[nNo + 1].fWeiyiAvg;
		m_vDataInfo[nNo + 1].fWeiyiAvg = fVal;

		CheckValue(m_vDataInfo[nNo + 1].fWeiyiAvg);
		for (int i = 0; i < 8; ++i)
		{
			if (m_HZProInfo.chChanelUsed[i] > 0)
			{
				m_vDataInfo[nNo + 1].fWeiyi[i] += fGap;
				CheckValue(m_vDataInfo[nNo + 1].fWeiyi[i]);
			}
		}
	}

	InitCalcData();
}

void CHZData::ModifyOriginalVal(int nNo, int nCol, float fVal, CString strBeiZhu)
{
	vector<DATA_INFO> DataInfo = GetDataInfo();
	HZ_PROJECT_INFO ProInfo = GetProjectInfo();
	if (nNo >= (int)DataInfo.size())
	{
		return;
	}
	
	if (0 == nCol)	//修改本级
	{
		if (g_DataType == DATA_0 || g_DataType == DATA_3)
		{
			int nBenjiId = DataInfo[nNo].nIdx;
			int nDataType = DataInfo[nNo].nJiaZaiOrXieZai;
			int nTimeId = DataInfo[nNo].nRecordId;
			for (int i = 0; i < (int)DataInfo.size(); ++i)
			{
				if (DataInfo[i].nIdx == nBenjiId && nDataType == DataInfo[i].nJiaZaiOrXieZai)
				{
					DataInfo[i].fLoadValue = fVal;
				}
			}
		}
		else if (g_DataType == DATA_1)
		{
			//先根据当前序号，计算出开始序号和结束序号
			int nBeginNo = 0, nEndNo = 0;
			GetMgDataNo(DataInfo, nNo, nBeginNo, nEndNo);
			for (int i = nBeginNo; i <= nEndNo; ++i)
			{
				DataInfo[i].fLoadValue = fVal;
			}
		}
		else if (g_DataType == DATA_2)
		{
			vector<int> vNums = GetSpDataRows(DataInfo);
			//本级的开始位置 和结束位置
			int nBeginNo = 0, nEndNo = 0;
			for (int i = 0; i < (int)vNums.size(); ++i)
			{
				if (i == 0)
				{
					nBeginNo = 0;
					nEndNo = vNums[0];
				}
				else
				{
					nBeginNo += vNums[i - 1];
					nEndNo += vNums[i];
				}

				if (nNo >= i && nNo < nEndNo)
				{
					for (int k = nBeginNo; k < nEndNo; k++)
					{
						DataInfo[k].fLoadValue = fVal;
					}
					break;
				}
			}
		}
	}
	else if (1 == nCol) //修改实测荷载
	{
		DataInfo[nNo].fCurLoad = fVal;
	}
	else if (2 == nCol) //修改实测油压
	{
		DataInfo[nNo].fCurYouya = fVal;
	}
	else if (3 == nCol) //修改记录时间
	{
		USES_CONVERSION;
		strcpy_s(DataInfo[nNo].chRecordTime,
			sizeof(DataInfo[nNo].chRecordTime), W2A(strBeiZhu));

		ReCalcOriTimeGap(DataInfo);
	}
	else if (5 == nCol) //平均位移
	{
		DataInfo[nNo].fWeiyiAvg += fVal;
		Carry(DataInfo[nNo].fWeiyiAvg, 2);
		for (int i = 0; i < 8; ++i)
		{
			if (ProInfo.chChanelUsed[i] > 0)
			{
				DataInfo[nNo].fWeiyi[i] += fVal;
				Carry(DataInfo[nNo].fWeiyi[i], 2);
			}
		}
	}
	else if (nCol >= 6 && nCol <= 13) //其他位移
	{
		Carry(fVal, 2);
		DataInfo[nNo].fWeiyi[nCol - 6] = fVal;
		int nCnt = 0;
		float fAvg = 0;
		for (int i = 0; i < 8; ++i)
		{
			if (ProInfo.chChanelUsed[i] > 0 && ProInfo.chChannelSel[i])
			{
				fAvg += DataInfo[nNo].fWeiyi[i];
				nCnt++;
			}
		}
		DataInfo[nNo].fWeiyiAvg = (float)(fAvg / (nCnt * 1.0));
		DataInfo[nNo].fWeiyiAvg = Carry(DataInfo[nNo].fWeiyiAvg, 2);
	}
	else if (14 == nCol) //修改备注
	{
		if (g_DataType == DATA_2 || g_DataType == DATA_3)
		{
			fVal = (float)_ttof(strBeiZhu);
			DataInfo[nNo].fShangZhuangShangBa = fVal;
		}
		else
		{
			USES_CONVERSION;
			int nLen = strlen(W2A(strBeiZhu));
			if (nLen >= 120)
			{
				strBeiZhu = strBeiZhu.Left(55);
			}
			strcpy_s(DataInfo[nNo].chBeiZhu,
				sizeof(DataInfo[nNo].chBeiZhu), W2A(strBeiZhu));
		}		
	}
	SetDataInfo(DataInfo);
	InitCalcData();
}

//原始记录修改加载级
// void CHZData::ModifyOriginalVal(int nNo, int nCol, float fVal, CString strBeiZhu)
// {
// 	if (nNo >= (int)m_vDataInfo.size())
// 	{
// 		return;
// 	}
// 	int nBenjiId = m_vDataInfo[nNo].nIdx;
// 	int nDataType = m_vDataInfo[nNo].nJiaZaiOrXieZai;
// 	int nTimeId = m_vDataInfo[nNo].nRecordId;
// 	if (0 == nCol)	//修改本级
// 	{
// 		ModifyLoad(nBenjiId, fVal, nDataType);
// 	}
// 	else if (1 == nCol) //修改实测荷载
// 	{
// 		m_vDataInfo[nNo].fCurLoad = fVal;
// 	}
// 	else if (2 == nCol) //修改实测油压
// 	{
// 		m_vDataInfo[nNo].fCurYouya = fVal;
// 	}
// 	else if (3 == nCol) //修改记录时间
// 	{
// 		USES_CONVERSION;
// 		strcpy_s(m_vDataInfo[nNo].chRecordTime,
// 			sizeof(m_vDataInfo[nNo].chRecordTime), W2A(strBeiZhu));
// 	}
// 	else if (5 == nCol) //平均位移
// 	{
// 		m_vDataInfo[nNo].fWeiyiAvg += fVal;
// 		CheckValue(m_vDataInfo[nNo].fWeiyiAvg);
// 		for (int i = 0; i < 8; ++i)
// 		{
// 			if (m_HZProInfo.chChanelUsed[i] > 0)
// 			{
// 				m_vDataInfo[nNo].fWeiyi[i] += fVal;
// 				CheckValue(m_vDataInfo[nNo].fWeiyi[i]);
// 			}
// 		}
// 
// 		if (nDataType == LOAD_VALUE)
// 		{
// 			m_vLoadData[nTimeId].vfWeiyi[nBenjiId] = m_vDataInfo[nNo].fWeiyiAvg;
// 		}
// 		else
// 		{
// 			m_vLoadOffData[nTimeId].vfWeiyi[nBenjiId] = m_vDataInfo[nNo].fWeiyiAvg;
// 			nBenjiId += (int)m_vLoadValue.size();
// 		}
// 		//判断当前修改位移是不是当前荷载最后一个位移
// 		BOOL bLast = FALSE;
// 		if (nNo >= (int)m_vDataInfo.size() - 1)
// 		{
// 			bLast = TRUE;
// 		}
// 		else
// 		{
// 			if (m_vDataInfo[nNo].nIdx == m_vDataInfo[nNo + 1].nIdx &&
// 				m_vDataInfo[nNo].nJiaZaiOrXieZai == m_vDataInfo[nNo + 1].nJiaZaiOrXieZai)
// 			{
// 				bLast = FALSE;
// 			}
// 			else
// 			{
// 				bLast = TRUE;
// 			}
// 		}
// 		if (bLast)
// 		{
// 			m_vSummaryData[nBenjiId].fAllDisp = m_vDataInfo[nNo].fWeiyiAvg;
// 			if (nBenjiId == 0)
// 			{
// 				m_vSummaryData[nBenjiId].fDispVal = m_vSummaryData[nBenjiId].fAllDisp;
// 			}
// 			else
// 			{
// 				m_vSummaryData[nBenjiId].fDispVal = m_vSummaryData[nBenjiId].fAllDisp - m_vSummaryData[nBenjiId - 1].fAllDisp;
// 			}
// 			if (nBenjiId < (int)m_vSummaryData.size() - 1)
// 			{
// 				m_vSummaryData[nBenjiId + 1].fDispVal = m_vSummaryData[nBenjiId + 1].fAllDisp - m_vSummaryData[nBenjiId].fAllDisp;
// 			}
// 		}
// 	}
// 	else if (nCol >=6 && nCol <=13) //其他位移
// 	{
// 		m_vDataInfo[nNo].fWeiyi[nCol - 6] = fVal;
// 		int nCnt = 0;
// 		float fAvg = 0;
// 		for (int i = 0; i < 8; ++i)
// 		{
// 			if (m_HZProInfo.chChanelUsed[i] > 0 && m_HZProInfo.chChannelSel[i])
// 			{
// 				fAvg += m_vDataInfo[nNo].fWeiyi[i];
// 				nCnt++;
// 			}
// 		}
// 		m_vDataInfo[nNo].fWeiyiAvg = (float)(fAvg / (nCnt * 1.0));
// 		CheckValue(m_vDataInfo[nNo].fWeiyiAvg);
// 
// 		if (nDataType == LOAD_VALUE)
// 		{
// 			m_vLoadData[nTimeId].vfWeiyi[nBenjiId] = m_vDataInfo[nNo].fWeiyiAvg;
// 		}
// 		else
// 		{
// 			m_vLoadOffData[nTimeId].vfWeiyi[nBenjiId] = m_vDataInfo[nNo].fWeiyiAvg;
// 			nBenjiId += (int)m_vLoadValue.size();
// 		}
// 
// 		//判断当前修改位移是不是当前荷载最后一个位移
// 		BOOL bLast = FALSE;
// 		if (nNo >= (int)m_vDataInfo.size() - 1)
// 		{
// 			bLast = TRUE;
// 		}
// 		else
// 		{
// 			if (m_vDataInfo[nNo].nIdx == m_vDataInfo[nNo + 1].nIdx &&
// 				m_vDataInfo[nNo].nJiaZaiOrXieZai == m_vDataInfo[nNo + 1].nJiaZaiOrXieZai)
// 			{
// 				bLast = FALSE;
// 			}
// 			else
// 			{
// 				bLast = TRUE;
// 			}
// 		}
// 		if (bLast)
// 		{
// 			m_vSummaryData[nBenjiId].fAllDisp = m_vDataInfo[nNo].fWeiyiAvg;
// 			if (nBenjiId == 0)
// 			{
// 				m_vSummaryData[nBenjiId].fDispVal = m_vSummaryData[nBenjiId].fAllDisp;
// 			}
// 			else
// 			{
// 				m_vSummaryData[nBenjiId].fDispVal = m_vSummaryData[nBenjiId].fAllDisp - m_vSummaryData[nBenjiId - 1].fAllDisp;
// 			}
// 			if (nBenjiId < (int)m_vSummaryData.size() - 1)
// 			{
// 				m_vSummaryData[nBenjiId + 1].fDispVal = m_vSummaryData[nBenjiId + 1].fAllDisp - m_vSummaryData[nBenjiId].fAllDisp;
// 			}
// 		}
// 	}
// 	else if (14 == nCol) //修改备注
// 	{
// 		USES_CONVERSION;
// 		int nLen = strlen(W2A(strBeiZhu));
// 		if (nLen >= 120)
// 		{
// 			strBeiZhu = strBeiZhu.Left(55);
// 		}
// 		strcpy_s(m_vDataInfo[nNo].chBeiZhu,
// 			sizeof(m_vDataInfo[nNo].chBeiZhu), W2A(strBeiZhu));
// 	}
// }

//标记获取值
/************************************************************************/
/* bLoad == TRUE 根据fLoad计算位移
/* bLoad == FALSE 根据位移计算fLoad值
/************************************************************************/
void CHZData::GetSignVal(float &fLoad, float &fWeiyi, BOOL bLoad)
{
	if (!g_bInitData)
	{
		return;
	}
	//判断值是否出范围
	BOOL bIn = FALSE;
	float f1 = 0;
	float f2 = 0;
	float fW1 = 0;
	float fW2 = 0;
	CString strf1(L""), strf2(L""), strfW1(L""), strfW2(L""), strfLoad(L""), strfWeiyi(L"");
	int i = 0;
	if (bLoad)
	{
		fWeiyi = 0;
		for (i = 1; i < (int)m_vSummaryData.size(); ++i)
		{
			f1 = m_vSummaryData[i - 1].fLoadVal;
			f2 = m_vSummaryData[i].fLoadVal;
			if (ValIsIn(f1, f2, fLoad))
			{
				bIn = TRUE;
				break;
			}
		}
		if (bIn)
		{
			fW1 = m_vSummaryData[i - 1].fAllDisp;
			fW2 = m_vSummaryData[i].fAllDisp;
			strf1.Format(L"%.02f", f1);
			strf2.Format(L"%.02f", f2);
			strfLoad.Format(L"%.02f", fLoad);
			if (f1 == f2)
			{
				fWeiyi = fW1;
			}
			else if (strf1 == strfLoad)
			{
				fWeiyi = fW1;
			}
			else if (strf2 == strfLoad)
			{
				fWeiyi = fW2;
			}
			else
			{
				fWeiyi = (fLoad * (fW1 - fW2) + (fW2*f1 - fW1*f2)) / (f1 - f2);
	//			fWeiyi = Carry(fWeiyi, 2);
			}
		}
	}
	else
	{
		fLoad = 0;
		for (i = 1; i < (int)m_vSummaryData.size(); ++i)
		{
			fW1 = m_vSummaryData[i - 1].fAllDisp;
			fW2 = m_vSummaryData[i].fAllDisp;
			if (ValIsIn(fW1, fW2, fWeiyi))
			{
				bIn = TRUE;
				break;
			}
		}
		if (bIn)
		{
			f1 = m_vSummaryData[i - 1].fLoadVal;
			f2 = m_vSummaryData[i].fLoadVal;
			strfW1.Format(L"%.02f", fW1);
			strfW2.Format(L"%.02f", fW2);
			strfWeiyi.Format(L"%.02f", fWeiyi);
			if (fW1 == fW2)
			{
				fLoad = f1;
			}
			else if (strfW1 == strfWeiyi)
			{
				fLoad = f1;
			}
			else if (strfW2 == strfWeiyi)
			{
				fLoad = f2;
			}
			else
			{
				fLoad = (fWeiyi * (f1 - f2) - (fW2*f1 - fW1*f2) ) / (fW1 - fW2);
//				fLoad = Carry(fLoad, 2);
			}
		}
	}
}

//大小值从小值开始排序 
BOOL CHZData::ValIsIn(float fVal_1, float fVal_2, float fVal)
{
	if (fVal_1 > fVal_2)
	{
		//互换
		fVal_1 = fVal_1 + fVal_2;
		fVal_2 = fVal_1 - fVal_2;
		fVal_1 = fVal_1 - fVal_2;
	}
	if (fVal >= fVal_1 && fVal <= fVal_2)
	{
		return TRUE;
	}
	return FALSE;
}

//添加标记值
BOOL CHZData::AddSignVal(float fLoad, float fWeiyi)
{
	if (!g_bInitData)
	{
		return FALSE;
	}
	float fMaxLoad = 0;
	float fMinLoad = 0;
	float fMaxWeiyi = 0;
	float fMinWeiyi = 0;
	
	GetMaxMinSum(fMaxLoad, fMinLoad, fMaxWeiyi, fMinWeiyi);
	if (fLoad > fMaxLoad || fLoad < fMinLoad || fWeiyi > fMaxWeiyi || fWeiyi < fMinWeiyi)
	{
		return FALSE;
	}
	m_HZProInfo.nSignCnts++;
	if (m_HZProInfo.nSignCnts > 20)
	{
		m_HZProInfo.nSignCnts = 20;
		return FALSE;
	}
	m_HZProInfo.nSignCnts < 1 ? 1 : m_HZProInfo.nSignCnts;

	m_HZProInfo.fSignHeZai[m_HZProInfo.nSignCnts - 1] = fLoad;
	m_HZProInfo.fSignWeiyi[m_HZProInfo.nSignCnts - 1] = fWeiyi;
	return TRUE;
}

//获取汇总最值
void CHZData::GetMaxMinSum(float &fLoadMax, float &fLoadMin, float &fWeiyiMax, float &fWeiyiMin)
{
	if (m_vSummaryData.empty())
	{
		return;
	}

	fLoadMax = -10000;
	fLoadMin = 10000;
	fWeiyiMax = -10000;
	fWeiyiMin = 10000;
	for (int i = 0; i < (int)m_vSummaryData.size(); ++i)
	{
		fLoadMax = fLoadMax < m_vSummaryData[i].fLoadVal ? m_vSummaryData[i].fLoadVal : fLoadMax;
		fLoadMin = fLoadMin > m_vSummaryData[i].fLoadVal ? m_vSummaryData[i].fLoadVal : fLoadMin;

		fWeiyiMax = fWeiyiMax < m_vSummaryData[i].fAllDisp ? m_vSummaryData[i].fAllDisp : fWeiyiMax;
		fWeiyiMin = fWeiyiMin > m_vSummaryData[i].fAllDisp ? m_vSummaryData[i].fAllDisp : fWeiyiMin;
	}
}

//恢复到原始数据
void CHZData::RestoreOriData()
{
	m_HZProInfo = m_HZProInfo_Old;
	m_vDataInfo = m_vDataInfo_Old;
	InitCalcData();
}

//加入卸载数据
void CHZData::AddLoadOffData()
{
	if (!g_bInitData)
	{
		return;
	}

	//获取本级
	vector<float> vVal;
	vVal.push_back(0);
	for (int i = 1; i < (int)m_vLoadValue.size() - 1; i += 2)
	{
		vVal.push_back(m_vLoadValue[i]);
	}
	//获取最后一个位移
	float fVal = 0;
	float fYouya = 0;
	CString strTime(L"");
	DATA_INFO Data_Info;
	if (m_vDataInfo.empty())
	{
		m_HZProInfo.nDataCnt = 0;
	}
	else
	{
		fVal = m_vDataInfo[(int)m_vDataInfo.size() - 1].fWeiyiAvg;
		fYouya = m_vDataInfo[(int)m_vDataInfo.size() - 1].fCurYouya;
		strTime = m_vDataInfo[(int)m_vDataInfo.size() - 1].chRecordTime;
	}
	USES_CONVERSION;
	ZeroMemory(&Data_Info, sizeof(Data_Info));
	Data_Info.fWeiyiAvg = fVal;
	Data_Info.fCurLoad = fVal;
	Data_Info.fCurYouya = fYouya;
	strcpy_s(Data_Info.chRecordTime, sizeof(Data_Info.chRecordTime), W2A(strTime));
	Data_Info.nJiaZaiOrXieZai = LOADOFF_VALUE;
	for (int i = 0; i < 8; ++i)
	{
		Data_Info.fWeiyi[i] = fVal;
	}
	int nCnt = (int)m_vDataInfo.size();
	for (int i = 0; i < (int)vVal.size(); ++i)
	{
		Data_Info.fLoadValue = vVal[(int)vVal.size() - 1 - i];
		Data_Info.nIdx = i;
		Data_Info.nRecordId = 0;
		Data_Info.nTimeGap = m_HZProInfo.nLoadOffTimeList[0];
	//	memcpy(&m_vDataInfo[nCnt], &Data_Info, sizeof(m_vDataInfo[nCnt]));
		m_vDataInfo.push_back(Data_Info);
		nCnt++;

		Data_Info.nRecordId = 1;
		Data_Info.nTimeGap = m_HZProInfo.nLoadOffTimeList[1];
		m_vDataInfo.push_back(Data_Info);
//		memcpy(&m_vDataInfo[nCnt], &Data_Info, sizeof(m_vDataInfo[nCnt]));
		nCnt++;
	}
//	m_HZProInfo.nDataCnt += (int)vVal.size() * 2;
	m_HZProInfo.nDataCnt = (int)m_vDataInfo.size();
	InitCalcData();
	ClearVector(vVal);
}

//导入excel数据
void CHZData::ImportExcelData_MY(vector<DATA_INFO> vDataInfo)
{
	if (!g_bInitData)
	{
		return;
	}
	//先分个类吧，太难了
	vector<vector<int>> vLoadNo;	//加载序号
	vector<vector<int>> vLoadOffNo; //卸载数据

	vector<int> vNo;
	float fLoadVal = 0;
	BOOL bLoad = TRUE;
	for (int i = 0; i < (int)vDataInfo.size(); ++i)
	{
		if (i == 0)
		{
			fLoadVal = vDataInfo[i].fLoadValue;
			vNo.push_back(i);
		}
		else
		{
			if (fLoadVal == vDataInfo[i].fLoadValue)
			{
				vNo.push_back(i);
			}
			else if (bLoad && fLoadVal > vDataInfo[i].fLoadValue)
			{
				bLoad = FALSE;
				vLoadNo.push_back(vNo);
				vNo.clear();
				vNo.push_back(i);
				fLoadVal = vDataInfo[i].fLoadValue;
			}
			else
			{
				if (bLoad)
				{
					vLoadNo.push_back(vNo);
					vNo.clear();
					vNo.push_back(i);
					fLoadVal = vDataInfo[i].fLoadValue;
				}
				else
				{
					vLoadOffNo.push_back(vNo);
					vNo.clear();
					vNo.push_back(i);
					fLoadVal = vDataInfo[i].fLoadValue;
				}
			}
		}
	}
	if (!vNo.empty())
	{
		if (bLoad)
		{
			vLoadNo.push_back(vNo);
		}
		else
		{
			vLoadOffNo.push_back(vNo);
		}
	}

	vector<DATA_INFO> vInfo;
	DATA_INFO DataInfo;
	int nBeijiId = 0;
	int nBeginNo = 0;
	int nCnt = 0;
	ZeroMemory(&DataInfo, sizeof(DATA_INFO));
	for (int i = 0; i < (int)vLoadNo.size(); ++i)
	{
		GetLoadValCnt(i, nBeginNo, nCnt, LOAD_VALUE);
		for (int n = 0; n < (int)vLoadNo[i].size(); ++n)
		{
			if (n < nCnt)
			{
				memcpy(&DataInfo, &m_vDataInfo[nBeginNo + n], sizeof(DATA_INFO));
			}
			if (n < 12)
			{
				DataInfo.nTimeGap = m_HZProInfo.nLoadTimeList[n];
			}
			else
			{
				DataInfo.nTimeGap = m_HZProInfo.nLoadTimeList[11];
			}
			DataInfo.nIdx = i;
			DataInfo.nRecordId = n;
			DataInfo.fLoadValue = vDataInfo[vLoadNo[i][n]].fLoadValue;
			DataInfo.fCurLoad = vDataInfo[vLoadNo[i][n]].fCurLoad;
			DataInfo.fWeiyiAvg = vDataInfo[vLoadNo[i][n]].fWeiyiAvg;
			memcpy(DataInfo.chRecordTime, vDataInfo[vLoadNo[i][n]].chRecordTime, 40);
			for (int k = 0; k < 8; ++k)
			{
				DataInfo.fWeiyi[k] = vDataInfo[vLoadNo[i][n]].fWeiyi[k];
			}
			DataInfo.nJiaZaiOrXieZai = LOAD_VALUE;
			DataInfo.fCurYouya = vDataInfo[vLoadNo[i][n]].fCurYouya;
			strcpy(DataInfo.chBeiZhu, vDataInfo[vLoadNo[i][n]].chBeiZhu);

			vInfo.push_back(DataInfo);
		}
	}

	for (int i = 0; i < (int)vLoadOffNo.size(); ++i)
	{
		GetLoadValCnt(i, nBeginNo, nCnt, LOADOFF_VALUE);
		for (int n = 0; n < (int)vLoadOffNo[i].size(); ++n)
		{
			if (n < nCnt)
			{
				memcpy(&DataInfo, &m_vDataInfo[nBeginNo + n], sizeof(DATA_INFO));
			}
			if (n < 12)
			{
				DataInfo.nTimeGap = m_HZProInfo.nLoadOffTimeList[n];
			}
			else
			{
				DataInfo.nTimeGap = m_HZProInfo.nLoadOffTimeList[11];
			}
			DataInfo.nIdx = i + (int)vLoadNo.size();
			DataInfo.nRecordId = n;
			DataInfo.fLoadValue = vDataInfo[vLoadOffNo[i][n]].fLoadValue;
			DataInfo.fCurLoad = vDataInfo[vLoadOffNo[i][n]].fCurLoad;
			DataInfo.fWeiyiAvg = vDataInfo[vLoadOffNo[i][n]].fWeiyiAvg;
			DataInfo.fCurYouya = vDataInfo[vLoadOffNo[i][n]].fCurYouya;
			memcpy(DataInfo.chRecordTime, vDataInfo[vLoadOffNo[i][n]].chRecordTime, 40);
			for (int k = 0; k < 8; ++k)
			{
				DataInfo.fWeiyi[k] = vDataInfo[vLoadOffNo[i][n]].fWeiyi[k];
			}
			DataInfo.nJiaZaiOrXieZai = LOADOFF_VALUE;
			strcpy(DataInfo.chBeiZhu, vDataInfo[vLoadOffNo[i][n]].chBeiZhu);
			vInfo.push_back(DataInfo);
		}
	}
	m_vDataInfo = vInfo;
	m_HZProInfo.chUnit = 0;
	m_HZProInfo.nDataCnt = (int)vInfo.size();
	InitCalcData();

	ClearVector(vLoadNo);
	ClearVector(vLoadOffNo);
	ClearVector(vNo);
	ClearVector(vInfo);
}

//导入excel数据
void CHZData::ImportExcelData(vector<DATA_INFO>	vDataInfo)
{
	if (!g_bInitData)
	{
		return;
	}
	//先分个类吧，太难了
	vector<vector<int>> vLoadNo;	//加载序号
	vector<vector<int>> vLoadOffNo; //卸载数据

	vector<int> vNo;
	float fLoadVal = 0;
	BOOL bLoad = TRUE;
	for (int i = 0; i < (int)vDataInfo.size(); ++i)
	{
		if (i == 0)
		{
			fLoadVal = vDataInfo[i].fLoadValue;
			vNo.push_back(i);
		}
		else
		{
			if (fLoadVal == vDataInfo[i].fLoadValue)
			{
				vNo.push_back(i);
			}
			else if (bLoad && fLoadVal >vDataInfo[i].fLoadValue)
			{
				bLoad = FALSE;
				vLoadNo.push_back(vNo);
				vNo.clear();
				vNo.push_back(i);
				fLoadVal = vDataInfo[i].fLoadValue;
			}
			else
			{
				if (bLoad)
				{
					vLoadNo.push_back(vNo);
					vNo.clear();
					vNo.push_back(i);
					fLoadVal = vDataInfo[i].fLoadValue;
				}
				else
				{
					vLoadOffNo.push_back(vNo);
					vNo.clear();
					vNo.push_back(i);
					fLoadVal = vDataInfo[i].fLoadValue;
				}
			}
		}
	}
	if (!vNo.empty())
	{
		if (bLoad)
		{
			vLoadNo.push_back(vNo);
		}
		else
		{
			vLoadOffNo.push_back(vNo);
		}
	}
	
	vector<DATA_INFO> vInfo;
	DATA_INFO DataInfo;
	int nBeijiId = 0; 
	int nBeginNo = 0; 
	int nCnt = 0;
	ZeroMemory(&DataInfo, sizeof(DATA_INFO));
	for (int i = 0; i < (int)vLoadNo.size(); ++i)
	{
		GetLoadValCnt(i, nBeginNo, nCnt, LOAD_VALUE);
		for (int n = 0; n < (int)vLoadNo[i].size(); ++n)
		{
			if (n < nCnt)
			{
				memcpy(&DataInfo, &m_vDataInfo[nBeginNo + n], sizeof(DATA_INFO));
			}
			if (n < 12)
			{
				DataInfo.nTimeGap = m_HZProInfo.nLoadTimeList[n];
			}
			else
			{
				DataInfo.nTimeGap = m_HZProInfo.nLoadTimeList[11];
			}
			DataInfo.nIdx = i;
			DataInfo.nRecordId = n;
			DataInfo.fLoadValue = vDataInfo[vLoadNo[i][n]].fLoadValue;
			DataInfo.fCurLoad = DataInfo.fLoadValue;
			DataInfo.fWeiyiAvg = vDataInfo[vLoadNo[i][n]].fWeiyiAvg;
			for (int k = 0; k < 8; ++k)
			{
				DataInfo.fWeiyi[k] = vDataInfo[vLoadNo[i][n]].fWeiyi[k];
			}
			DataInfo.nJiaZaiOrXieZai = LOAD_VALUE;
			DataInfo.fCurYouya = vDataInfo[vLoadNo[i][n]].fCurYouya;
			strcpy(DataInfo.chBeiZhu, vDataInfo[vLoadNo[i][n]].chBeiZhu);

			vInfo.push_back(DataInfo);
		}
	}

	for (int i = 0; i < (int)vLoadOffNo.size(); ++i)
	{
		GetLoadValCnt(i, nBeginNo, nCnt, LOADOFF_VALUE);
		for (int n = 0; n < (int)vLoadOffNo[i].size(); ++n)
		{
			if (n < nCnt)
			{
				memcpy(&DataInfo, &m_vDataInfo[nBeginNo + n], sizeof(DATA_INFO));
			}
			if (n < 12)
			{
				DataInfo.nTimeGap = m_HZProInfo.nLoadOffTimeList[n];
			}
			else
			{
				DataInfo.nTimeGap = m_HZProInfo.nLoadOffTimeList[11];
			}
			DataInfo.nIdx = i + (int)vLoadNo.size();
			DataInfo.nRecordId = n;
			DataInfo.fLoadValue = vDataInfo[vLoadOffNo[i][n]].fLoadValue;
			DataInfo.fCurLoad = vDataInfo[vLoadOffNo[i][n]].fCurLoad;
			DataInfo.fWeiyiAvg = vDataInfo[vLoadOffNo[i][n]].fWeiyiAvg;
			DataInfo.fCurYouya = vDataInfo[vLoadOffNo[i][n]].fCurYouya;
			for (int k = 0; k < 8; ++k)
			{
				DataInfo.fWeiyi[k] = vDataInfo[vLoadOffNo[i][n]].fWeiyi[k];
			}
			DataInfo.nJiaZaiOrXieZai = LOADOFF_VALUE;
			strcpy(DataInfo.chBeiZhu, vDataInfo[vLoadOffNo[i][n]].chBeiZhu);
			vInfo.push_back(DataInfo);
		}
	}
	m_vDataInfo = vInfo;
	m_HZProInfo.chUnit = 0;
	m_HZProInfo.nDataCnt = (int)vInfo.size();
	InitCalcData();

	ClearVector(vLoadNo);
	ClearVector(vLoadOffNo);
	ClearVector(vNo);
	ClearVector(vInfo);
}

//获取工程每个加载级的开始位置和个数
void CHZData::GetLoadValCnt(int nBenjiId, int &nBeignNo, int &nCnt, int nDataType)
{
	int nCount = 0;
	nBeignNo = 0;
	nCnt = 0;
	for (int i = 0; i < (int)m_vSummaryData.size(); ++i)
	{
		if (nBenjiId == m_vSummaryData[i].nBenJiId && nDataType == m_vSummaryData[i].nJiaZaiOrXieZai)
		{
			nBeignNo = nCount;
			nCnt = m_vSummaryData[i].nDataCnt;
			nCount += m_vSummaryData[i].nDataCnt;
			break;
		}
	}
}

//修正平均位移
void CHZData::CalcAvfWeiyi()
{
	if (g_systemSet.bSameData)
	{
		for (auto &info : m_vDataInfo)
		{
			int nCnt = 0;
			float fAvg = 0;
			for (int i = 0; i < 8; ++i)
			{
				if (m_HZProInfo.chChanelUsed[i] > 0 && m_HZProInfo.chChannelSel[i])
				{
					info.fWeiyi[i] = Carry(info.fWeiyi[i], 2);
					fAvg += info.fWeiyi[i];
					nCnt++;
				}
			}
			if (nCnt == 0)
			{
				continue;
			}
			info.fWeiyiAvg = (float)(fAvg / (nCnt * 1.0));
			info.fWeiyiAvg = Carry(info.fWeiyiAvg, 2);
		}
	}
	else
	{
		for (auto &info : m_vDataInfo_Old)
		{
			int nCnt = 0;
			float fAvg = 0;
			for (int i = 0; i < 8; ++i)
			{
				if (m_HZProInfo_Old.chChanelUsed[i] > 0 && m_HZProInfo_Old.chChannelSel[i])
				{
					info.fWeiyi[i] = Carry(info.fWeiyi[i], 2);
					fAvg += info.fWeiyi[i];
					nCnt++;
				}
			}
			if (nCnt == 0)
			{
				continue;
			}
			info.fWeiyiAvg = (float)(fAvg / (nCnt * 1.0));
			info.fWeiyiAvg = Carry(info.fWeiyiAvg, 2);
		}
	}
	InitCalcData();
}